<svg width="68" height="12" viewBox="0 0 68 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M68 0H0V12H68V0ZM7.545 4.13L6 1L4.455 4.13L1 4.635L3.5 7.07L2.91 10.51L6 8.885L9.09 10.51L8.5 7.07L11 4.635L7.545 4.13ZM21.545 4.13L20 1L18.455 4.13L15 4.635L17.5 7.07L16.91 10.51L20 8.885L23.09 10.51L22.5 7.07L25 4.635L21.545 4.13ZM34 1L35.545 4.13L39 4.635L36.5 7.07L37.09 10.51L34 8.885L30.91 10.51L31.5 7.07L29 4.635L32.455 4.13L34 1ZM49.545 4.13L48 1L46.455 4.13L43 4.635L45.5 7.07L44.91 10.51L48 8.885L51.09 10.51L50.5 7.07L53 4.635L49.545 4.13ZM62 1L63.545 4.13L67 4.635L64.5 7.07L65.09 10.51L62 8.885L58.91 10.51L59.5 7.07L57 4.635L60.455 4.13L62 1Z" fill="#5CC172"/>
<path d="M6 1L7.545 4.13L11 4.635L8.5 7.07L9.09 10.51L6 8.885L2.91 10.51L3.5 7.07L1 4.635L4.455 4.13L6 1Z" stroke="#F16617" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M20 1L21.545 4.13L25 4.635L22.5 7.07L23.09 10.51L20 8.885L16.91 10.51L17.5 7.07L15 4.635L18.455 4.13L20 1Z" stroke="#F16617" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M34 1L35.545 4.13L39 4.635L36.5 7.07L37.09 10.51L34 8.885L30.91 10.51L31.5 7.07L29 4.635L32.455 4.13L34 1Z" stroke="#F16617" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M48 1L49.545 4.13L53 4.635L50.5 7.07L51.09 10.51L48 8.885L44.91 10.51L45.5 7.07L43 4.635L46.455 4.13L48 1Z" stroke="#F16617" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M62 1L63.545 4.13L67 4.635L64.5 7.07L65.09 10.51L62 8.885L58.91 10.51L59.5 7.07L57 4.635L60.455 4.13L62 1Z" stroke="#F16617" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
import {useState, useCallback} from 'react';
export default () => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const request = useCallback(async (url, method = `GET`, body = null, headers = {}) => {
setLoading(true);
try {
if (body) {
body = JSON.stringify(body);
headers[`Content-Type`] = `application/json`;
}
const response = await fetch(url, { method, body, headers });
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || 'Something went wrong');
}
setLoading(false);
return data;
} catch (e) {
setLoading(false);
setError(e.message);
throw e;
}
}, []);
const clearError = useCallback(() => setError(null), []);
return {loading, request, error, clearError}
}
const {loading, request, error, clearError} = useHttp();
const handler = async () => {
const response = await request(`/api/auth/login`, `POST`, {...form}); // можно четвертым передать headers
}
if (loading) {} // если грузятся данние
if (error) {} // если прозойшла ошибка
var data = {
types: {
type_1: {
max_speed: 300
},
type_2: {
max_speed: 260
}
},
TC: {
transport_1: {
color: "red",
type: "type_2"
},
transport_2: {
color: "blue",
type: "type_1"
}
}
}
var tc = data.TC.transport_1;
console.log("Car:", tc.color); //red
console.log("Speed:", data.types[tc.type].max_speed); //260
{
"types": {
"type_1": {
"max_speed": 300
},
"type_2": {
"max_speed": 260
}
},
"TC": {
"transport_1": {
"color": "red",
"type": "type_2"
},
"transport_2": {
"color": "blue",
"type": "type_1"
}
}
}
wordStr += str[i];
newStr[i] = str[strLength - 1 - i];
newStr += str[strLength - 1 - i];
const ex = "My favourite game";
function wordReverse(str) {
var newStr = '',
strLength = str.length;
for (var i = 0; i < strLength; i++) {
newStr += str[strLength - 1 - i];
}
return newStr;
}
function wordsReverse(str) {
str += " ";
var wordsReverseArray = [],
wordStr = "";
for(var i=0; i<str.length; i++) {
if(str[i] !== " ") {
wordStr += str[i];
} else {
wordsReverseArray.push(wordReverse(wordStr));
wordStr = "";
}
}
return wordsReverseArray.join(' ');
}
console.log(wordsReverse(ex)); // "yM etiruovaf emag"
$z = $_REQUEST['qwerty'];
$y = array_rand($x);