Learn Before
Concept
Conditionally assigning JSX to a variable in React Js
With an "if" statement, you can reassign a "let" variable. First, set the default value that you want to display. Then, in the "if" condition, you can reassign the variable.
let itemContent = name; if (isPacked) { itemContent = name + " ✔"; } <li className="item"> {itemContent} </li>
0
1
Updated 2023-03-22
Tags
JavaScript Programming Language
Object-Oriented Programming
Programming Language Paradigms
General programming languages
Computing Sciences