26. Change Variable Values Problem


#1

This is what I have so far but I just keep getting "AB" in the running screen and an error that says you didn't log your whole name into the console. What do I do?
// On line 2, declare a variable myName and give it your name.
var myName = "ABCD";
// 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 = "ABCD".substring(0,2);
// On line 9, use console.log to print out the myName variable.
console.log=(myName);


#2

the equal sign is used to assign a value to a variable, if you want to log something to the console, you should use:

console.log("whatever it is you want to log")';

no equal sign there, you don't have a variable you want assign a value too.


#3

Hey guys
need help
// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = "england"

// Use console.log to print out the length of the variable myCountry.
console.log ("myCountry".length)

// Use console.log to print out the first three letters of myCountry.
console.log("myCountry".substring(0,3))
it says that i didn't log the length and can you help?


#4

Also after fixing this = sign problem with console.log refresh the page to reset console.log to its old value. Otherwise you might get the "console.log is not a function error".


#5

"myCountry".length prints the length of "myCountry" but to see the length of "england", which is currently stored in myCountry you would need to use myCountry.length instead.


#6

Thanks and another one

      
        **Instructions**
      
      
        Under your existing code, print out the storyline:

"Suddenly, Bieber stops and says, 'Who wants to race me?'"Then declare a variable userAnswer. Make it equal a prompt that asks the user "Do you want to race Bieber on stage?". This will be the question that you ask your user.

      
    **my code**

confirm("I am ready")
var age = prompt("what is your age")
if(age < 13){
console.log("ok but don't")
}
else{
console.log("oh yes")
}
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'")
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")
var userAnswer = prompt("Do you want to race Bieber on stage?")
it says - Did you remember to console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'"); ?


#7

If you reply to an existing question, and not provide a link to the exercise, that is tricky (please provide link to exercise). I am not going to start counting how many semi-colons are missing, but i guess quit a few


#8

thanks this solved it


#9

what line does this apply too?


#10

all of jackery_007 lines which use console.log, they are all faulty


#11

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


#12

so confused i dont get it


#13

could you be a bit more specific what part is unclear and what do you already wrote?


#14

keeps on sayng, Oops, try again. It looks like you didn't log your whole name to the console.


#15

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


#16
console.log=(myName);

this seems to be the problem, because here you overwrite the value of console.log (which is a fancy function that prints to the console) with "Chantel". So not only is nothing printed but this also breaks the ability to print something. So what you need to do is to make it a function call again:

console.log(myName);

and the refreseh the page to reset the value of console.log back to its printing-to-the-console ability. (Both on line 4+9).


#17

ok thanks just solved now


#18

Hey all - I just keep getting the "Oops, try again. It looks like you didn't log your whole name to the console." I've pasted what I have below. Any ideas??

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


#19

you print the string myName on line 9, this should be the variable, remove the quotation marks ("), same online 7, you use a variable and want a substring of it, no need for quotation marks


#20

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

// put it in this format it will work