const str = "{'id':'147','name':'example's name1','address':'sample street 1'}";
const [_, id, name, address] = str.match(/{'id':'(.*?)','name':'(.*?)','address':'(.*?)'}/);
console.log(id); // 147
console.log(name); // example's name1
console.log(address); // sample street 1const re = /{'id':'(?<id>.*?)','name':'(?<name>.*?)','address':'(?<address>.*?)'}/;
const result = re.exec("{'id':'147','name':'example's name1','address':'sample street 1'}");
console.log(result.groups);
// Object { id: "147", name: "example's name1", address: "sample street 1" } char str[] = "Hello"; - здесь создаётся массив и инициализируется символами из строки.const char *str = "Hello"; - здесь создаётся скалярная переменная-указатель и инициализируется указателем на строку в памяти.const int *mas = { 4, 5, 7, 9 }; - здесь вы пытаетесь создать переменную-указатель, а инициализировать её как массив, что недопустимо.const char *strArr[] = { "Hello", "world", "and" }; - здесь создаётся массив указателей и инициализируется массивом указателей на строки. Правильно читается как (*strArr)[], а не *(strArr[]) const increaseSalary = async () => {
try {
const employees = await api.getEmployees();
const employee = employees.reduce(
(acc, cur) => (acc.salary > cur.salary ? cur : acc),
{ salary: Infinity },
);
const newSalary = (employee.salary * 1.2) | 0;
const result = await api.setEmployeeSalary(employee.id, newSalary);
if (result.salary !== newSalary) {
throw 'API Error, salary has not increased';
}
await api.notifyEmployee(
employee.id,
`Hello, ${employee.name}! Congratulations, your new salary is ${newSalary}!`,
);
return true;
} catch (e) {
api.notifyAdmin(e.message);
return false;
}
});