26 Change Variable Values


#1

I had trouble with this one myself. Here is good guideline on how to do this exercise. Hope this helps.

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


#2

The optimum word there is myName. Now that we have it as a reference to your name represented in a string primitive, we no longer need refer to the primitive. We have the variable.

console.log(myName);           // Andrew

Likewise as we continue, the variable will be used in conjunction with the string method...

// On line 7, change the value of myName to be just the first 2 
// letters of your name.
myName = myName.substring(0,2);

and in the end, repeat line 4.