To declare a string variable named text with the value 'Hello World' in JavaScript, you would write _________.
- var text = "Hello World";
- var text := "Hello World";
- string text = "Hello World";
- text = "Hello World";
To declare a string variable in JavaScript, you use the var keyword followed by the variable name (text) and assign the value (Hello World) using the equal sign (=). The correct syntax is var text = "Hello World";. Variables are case-sensitive in JavaScript, so make sure the variable name matches the case.
Loading...
Related Quiz
- In which scenario is a function expression preferred over a function declaration?
- Which of the following is a way to create a singleton object in JavaScript?
- JavaScript was introduced to the world in the year _________.
- How can you handle errors in the fetch API when using async/await syntax?
- In JavaScript, the _______ method is used to create a new object using an existing object as the prototype of the newly created object.