26.change the variable


#1


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

Replace this line with your code.


#2

What is the error? Please describe your problem and post error message.


#3

i didn't log my whole name console.


#4

Step 1. You need declare a variable myName and give it your name.

var myName = "sharon";

Step 2. You need log myName variable:

console.log(myName); // logs "sharon"

Step 3. You need change the value of myName to be just the first 2:

myName = "sh"; // you don't need keyword var because myName was declared earlier

Step 4. You need log myName variable

console.log(myName); // logs "sh"

So step 3 rewrites myName value from "sharon" to "sh" and you can't log whole name after it, only "sh".


#5

ok...i have solve it thank you :slight_smile:


#6

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