Variables cannot be used until they have been declared.*
The code sample has an error because the variable str was never declared. Run the code to see how the assignment fails because the variable has not been declared yet.
Fix the code by declaring the variable str on the first line before it is used.
* You actually can assign a value to a variable before it is declared in regular JavaScript, but CodeSteps.dev uses JavaScript's "strict mode" which prohibits such assignments because they can be confusing.
Output (Console)