Changing a variable name


#1


javascript... i have a variable myName and want to change its value to the first two letters of the myName variable
 var myName = "home";
 myName = myName.substring(0,2);
console.log(myName);
dosnt work in my codecadamy workspace


#2

Have you tried switching the browser?


#3

just that i new to programming and taking it slow not to confuse myself should i try to switch browsers.. difficulty in setting the browser to recognize my script code


#4

Ok so first off you don't need a substring for this lesson. To help explain your errors I believe referring to the comments in the code is most beneficial. Your first line is fine. The second line is where the problem begin. "// On line 4, use console.log to print out the myName variable." So here you should console.log(myName); so move that part of your code to where your myName = myName.substring(0,2) used to be before you deleted it. Then, "// On line 7, change the value of myName to be just the first 2 letters of your name." So for your third part you should have the first to letters of home being = to myName so something like this:

myName = "ho";

For the fourth step you need to console.log myName again so copy and paste that here as well. All in all your whole code should look something like this:

var myName = "home";
console.log(myName);
myName = "ho";
console.log(myName);

#5

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