Executing JavaScript code
You can not only insert variables and constants inside curly brackets, but also execute arbitrary JavaScript code. Let's, for example, find the sum of two constants at the moment of insertion:
jsxfunction App() {
const num1 = 1;
const num2 = 2;
return <div>
{num1 + num2}
</div>;
}
Задание 1
What HTML will result from rendering the following code:
jsxfunction App() {
const num1 = 3;
const num2 = 2;
return <div>
result: {num1 ** num2}
</div>;
}
Задание 2
What HTML will result from rendering the following code:
jsxfunction App() {
const name = 'john';
const surname = 'smit';
return <div>
result: {name + ' ' + surname}
</div>;
}
Задание 3
What HTML will result from rendering the following code:
jsxfunction App() {
const num = 4;
return <div>
result: {Math.sqrt(num)}
</div>;
}