Basic JavaScript - Declare String Variables

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

var = myFirstName;
myFirstName = "ramanuj";
var = myLastName;
myLastName = "ghosal"

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 12; SM-P615) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Declare String Variables

Link to the challenge:

somehow after writeing alll of this the thing is not working

yep later i did out the semicolond but still no result

What’s exactly not working ? please explain

There’s not supposed to be an “=” sign between the var keyword and the name of the variable you are trying to create.

  1. var = myFirstName; is not correct syntax and will throw an error.
  2. var myFirstName; is using correct syntax and will not throw an error.

In 1. you are trying to set var equal to the value of myFirstName, which is not possible as var is a reserved keyword.

In 2. you are stating that myFirstName is a var.

Use the following syntax if you wish to create variables in the future,

var myVariable = "Hello, world!";

var myFirstName = "ramanuj";

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.