26.Change Variable Values


#1


// On line 2, declare a variable myName and give it your name.
var "myName" = "Maddy";
// On line 4, use console.log to print out the myName variable.
console.log("myName");
// On line 7, change the value of myName to be just the first 2 
// letters of your name.
"myName"= ("myName".substring(0,2))
// On line 9, use console.log to print out the myName variable.
console.log("myName");

I have this. It keeps giving me a syntax error, but I don't understand what I'm doing wrong!


#2

Your calling myName as a string instead of a variable. When it tells you to use the myName variable then just remove the quotation marks around it :slight_smile:


#3

when you declare a variable you don't need to put quotations around it. var myName = "chris".


#4

write like this

var myName = "zabihullah maiwandi";

console.log(myName);

varibale name declear like this : var name = value ;

varible name dont write in double quotation


#5

var myName = Maria;

console.log(myName)

myName = "myName.subscript(0,2)"

console.log(myName)

//Why is this not working?


#6

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