⊗jsrtPmJxRC 24 of 112 menu

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:

function App() { const num1 = 1; const num2 = 2; return <div> {num1 + num2} </div>; }

What HTML will result from rendering the following code:

function App() { const num1 = 3; const num2 = 2; return <div> result: {num1 ** num2} </div>; }

What HTML will result from rendering the following code:

function App() { const name = 'john'; const surname = 'smit'; return <div> result: {name + ' ' + surname} </div>; }

What HTML will result from rendering the following code:

function App() { const num = 4; return <div> result: {Math.sqrt(num)} </div>; }
enru