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


#1

// On line 2, declare a variable myName and give it your name.
var myName = "cody";
// 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.
myName = (myName.substring(0,2));
// On line 9, use console.log to print out the myName variable.
console.log = (myName);
..?.. Oops, try again. It looks like you didn't log your whole name to the console.


Question 26/28
#2

As far as i can see the general idea is ok your using variables like they are supposed to be used it is just that this statement is "evil":

console.log = (myName);

If you look closely you'll see that it fits an A = B scheme, meaning your assigning a new value to console.log which makes it unable to perform it's original task to print stuff to the console. What you want to do instead is using it by writing:

console.log(myName);

unfortunately the damage is done so fixing this alone wouldn't get rid of the problem because now console.log really is an alias for "cody". So in order to fix this you would need to refresh the page as well as this will reset console.log to its original value, which lets you perform the writing to the console stuff.


#3

my instructor used my account name instead of cody and fixed the "whole name" problem i also took out the =


#4

A post was split to a new topic: 26. I did this and I got green Way to go, but It looks it is not printing new var defined


#5

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