Calling functions inside tags in React
Functions can be called directly within curly braces:
function App() {
function square(num) {
return num ** 2;
}
return <div>
{square(3)}
</div>
}
You can also make calls to multiple functions within curly braces:
function App() {
function square(num) {
return num ** 2;
}
function cube(num) {
return num ** 3;
}
return <div>
{square(3) + cube(4)}
</div>
}
Using the function you created getDigitsSum
, output the sum of the digits of the number 12345
into a paragraph.