26. I did this and I got green Way to go, but It looks it is not printing new var defined


#1

I did this and I got green Way to go, but It looks it is not printing new var defined

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

So I think that this should be like this, also working:

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


26. It looks like you didn't log your whole name to the console
#2

Your code is printing the value, not the variable.

console.log(myName);

Your code is doing this literally, rather than dynamically. Do not redeclare the variable, it already is declared, and the definition it is given should remain in tact, upcoming changes notwithstanding...

myName = myName(substring(0,2));

Again, print the variable, not the value.

console.log(myName);

#3

Thanks for the comment, but as I understood it is required to be changed:


#4

Redeclare variables at your own peril. You are warned.


#5

A post was split to a new topic: 26. It looks like you didn't log your whole name to the console


#6

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