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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *