Lesson 26 There is something wrong with my code)


#1

There is something wrong with my code, but i can not locate where i have gone wrong. Could someone please help me.

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


#2

here:

console.log = (myName);

to log something to the console, you need to use console.log() like you did on line 4


#3

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


#4

So i made so changes but it still isnt working


#5

except you made the change the wrong way around, console.log() is a built in function, what you did is create a variable named console.log


#6

oh ok, Lol thank you aye way


#7

Ok so if i am not mistaken it should look something like this:

// On line 2, declare a variable myName and give it your name.
var myName = "Toby";
// 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);


#8

but that still doesn't work, i am honestly so confused right now.


#9

see...
http://prntscr.com/fko68q


#10

refresh the page/try different browser, your browser is very likely sending cached data


#11

I had the same problem I was using FireFox - It works on Chrome! :smiley:


#12

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