Hi
I am not quite sure what it is you want to achieve here.
with your code you should just get a 0 (Zero) output on your page.
Check is inside the {} so it is treated as JS
as it is zero it can also be seen as a boolean value (false).
If you set it to 1 it would be seen as true.
If you want to output "0 & Hello" you need to use & amp not &&
&& is seen as a comparison in an if.
So you would need another value after the && to check against
If you want to test the "check" state you can either use an if
statement outside the return or inline the if using a ?
function App() {
const check = 0;
let result = "";
if (check) {
result = <span>Hello result 1</span>;
} else {
result = <span>Hello result 0</span>;
}
return (
<div >
<span>Hello all</span>
<hr />
{ check} & <span>Hello check</span>
<hr />
{ result}
<hr />
{ check ? <span>Hello check 1</span> : <span>Hello check 0</span>}
</div >
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);