26.Change Variable Values


#1

// On line 2, declare a variable myName and give it your name.
var myName = "Adam";
// 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.
console.log("myName".substring(0,3));
// On line 9, use console.log to print out the myName variable.
console.log("myName")

So this is what I have but the consoles not logging my Variable, I've looked around, reset, and refreshed multiple times I don't get it. This should be correct, am I wrong?


#2

These two things are not the same:

myName 
"myName"

Do you want to use a variable or a string consisting of the letters "myName"?


#3

lol thank you very much :slight_smile:


#4

well I thought I had it I'm just trying to create a variable and define it, then have that variable log in the console as a couple strings and a substring


#5

This is perfect:

var myName = "Adam";

This is not, unless your goal is to log the letters "myName":

console.log("myName");

Do you understand how to fix that?


#6

got it thanks a bunch feel pretty dumb just started this, goes from being super easy to getting stuck on something silly. Now that I think about it it seems so obvious lol. I am enjoying learning it though


#7

as long as you learn....don't worry.


#8

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