This forum is now read-only. Please use our new forums! Go to forums
Do Not put quotes in "myCountry"
Hi fellows, Please do not wrap a variable in quotes.
This seems to be a common problem.
Once a word has been declared as a *variable*
it becomes a ' reserved' word.
If you wrap it in quotes it loses the variable power because it becomes just a string of characters.
Examples:
var myCountry = "USA";
console.log(myCountry.length);
console.log(myCountry.substring(0,3));
- “USA” is wrapped in quotes because it is a string of characters.
- myCountry should not take quotes because it is a variable.
A variable is a memory location where we can save data.
Another example:
var myNumber = 333;
- Although 333 is data just like “USA”, it does not get wrapped with quotes because it is a number.
Only strings of characters get wrapped in quotes.
If I write “333”, the value becomes a string of characters, 3 being the character. The problem with this is that it can not be used in math.
Hope it makes sense.
Answer 55115b5e51b8872fc70020f4
You’re welcome, everyone! It is a pleasure to be able to assist you and learn from all of you as well! Cheers!
Answer 55299cf7937676d3f10004db
Hey, thank you for the response, I was going crazy. If this is a common issue, might I recommend changing the Hint for it. The hint honestly offers little to no explanation for this particular problem. :)
2 comments
The hint is on part 24/28 of this section in the introduction for “Variables”. I actually had a problem with this section and found help in this forum, but once I went back to review things I found the hint that was given.
thanks man it was very usefull
Answer 5504cfaa95e378bf1c00526f
Make sure the C in myCountry is capitalized as well ;)
5 comments
hey
but why?
thank you guys!!! I almost spent the whole night trying to figuer this out
that is just a style choice though right ?
For the purposes of the lesson, you’re going to have to type the variable exactly as the lesson asks. If you declare the variable as mycountry, you might’ve well said “fruit” or “JohnTravolta” JS is super literal, the lessons are super literal. It’s good practice.
Answer 553f6c70d3292f9c210001d5
var myCountry = “New York”; console.log(“New York”.length); console.log(“New York”.substring(0,3));
7 comments
Thanks you :)
thanks
Thank You!
Nice. That was bugging me for ages.
cheers mate. the thing has really taken some of my time to crack it up.
ahahahahahhahahahahhahaa
Thank You! c:
Answer 552ce6c59113cb224e000541
Question is // Declare a variable on line 3 called // myCountry and give it a string value.
here is my code lines,
var myName= myCountry;
console.log(myName);
and this
var name= myCountry;
console.log(myCountry.length);
console.log(myCountry.substring(0,3));
but i got this error
ReferenceError: myCountry is not defined
let me guide on this.
4 comments
var myCountry= “name of your country”; console.log(myCountry.length); console.log(myCountry.substring(0,3));
needs quotes
Thank You!
I’ve made it like this and it got run:
// Declare a variable on line 3 called // myCountry and give it a string value. var myCountry = “Ukraine”; // Use console.log to print out the length of the variable myCountry. console.log(“Ukraine”.length);
// Use console.log to print out the first three letters of myCountry. console.log(myCountry.substring(0,3) );
Answer 553944f595e3780a880001e0
1 comments
kdjasd
Answer 557aa2119376767c5e000025
Answer 560004d951b88757ed000321
Answer 551826ae76b8fe81bc003a18
1 comments
well done
Answer 55182764e39efea2f000399e
My code looks exactly like yours, Tony, but I get the “Oops, try again” message every time.
Here is my code: var myCountry = “United States of America”;
console.log(“myCountry”.length);
console.log(“myCountry”.substring(0, 3));
My variable assignation isn’t “catching.” My code evaluates to: 9 myC
3 comments
Hi, read the title of my post. That is your problem. Remove the quotes from “myCountry”. If you still have problems after that, refresh the browser with CTRL + f5 ( or CMD + r if on a MAC). Good luck!
Yikes - I was only looking at where I was assigning the variable. Thanks!
:))) glad to know it worked out for you!
Answer 551b6fcd937676e4f3000793
Answer 5524404251b887e3bb000093
The following text is our instructions:
“For example: var myName = “Steve Jobs”; myName.substring(0,5) Look at the second line above. You have asked the computer to swap out myName and swap in Steve Jobs, so myName.substring(0,5) becomes “Steve Jobs”.substring(0,5) which evaluates to Steve.”
So see why we are doing what we do now? Thanks.
Answer 5525d25576b8fe462f0005cc
This is what I am doing for code:
// Declare a variable on line 3 called // myCountry and give it a string value. var myCountry = “Narnia”;
“Narnia”.substring(0,6);
// Use console.log to print out the length of the variable myCountry. console.log(myCountry.substring(0,6));
// Use console.log to print out the first three letters of myCountry. console.log(myCountry.substring(0,3));
It keeps telling me: It looks like you didn’t log the length of myCountry to the console.
I am getting so frustrated; I am just not seeing what I’m doing wrong.
6 comments
I tried it with all “myCountry” and all “Narnia” - so (0,9) and (0,6) - and then with and without quotes…. it just keeps saying it’s wrong
HA - I needed to use the word “length” - LOL all that time spent for something so simple :/
mine is same as yours…but i’m still getting error(ReferenceError: myCountry is not defined) var myCounrty = “Pakistan”; console.log(myCountry.length); console.log(myCountry.substring(0,3));
Write like this var myCountry = “Pakistan’ ;
im getting console.log is not a function
I got stuck on the same thing for about an hour……. try this it worked out for me. // Declare a variable on line 3 called // myCountry and give it a string value. var myCountry = “Makicar”;
// 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));
Answer 552ce81b76b8fe180b000059
great post, i got the answer of my error. :)
thats wonderful. i spend 1 hr on this exercise.
Answer 5557904e51b887f186000540
Answer 5572b855d3292f2f5000050f
// Declare a variable on line 3 called // myCountry and give it a string value.
var myCountry="krypton";
// Use console.log to print out the length of the variable myCountry.
console.log("krypton".length);
// Use console.log to print out the first three letters of myCountry.
console.log("krypton".substring(0,3));
output: 7 kry
how i get output.its strange??
3 comments
*did
shouldnt it be console.log(myCountry.length); ?
var myCountry = “New York”; console.log(“New York”.length); console.log(“New York”.substring(0,3)); Try this one
Answer 557c61d4d3292fb5e30002a4
Answer 5599fd55d3292f68020005fe
var myCountry = “USA”; console.log (myCountry.length); console.log (myCountry.substring (0,3));
no quotes around myCountry. I got 3, USA
Answer 55b8d3fde39efedd1d0002bb
Answer 55be04b5937676dda60005d7
Help!
**// On line 2, declare a variable myName and give it your name.
var myName = "Beka";
// On line 4, use console.log to print out the myName variable.
console.log("Beka")
// On line 7, change the value of myName to be just the first 2
// letters of your name.
var myName = "Salmoorbek";
// On line 9, use console.log to print out the myName variable.
console.log("Salmoorbek")
**
It seems to have written as it is, I do not understand what it was, whether knows everything about this is not right!
Answer 560241bd51b887c460000156
// Declare a variable on line 3 called // myCountry and give it a string value. var myCountry console.log (mycountry = USA) // 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))
its still not working
Answer 5605b2b69113cb858400022e
Thank you for the help. I was stuck on this script for a month now. Writing codes is fun
Answer 55d89a08e39efe7ebb000164
var myCountry = “New York”; console.log(“New York”.length); console.log(“New York”.substring(0,3));
Try this one..
1 comments
You should NEVER retype the value once the value has been declared. Always retype the variable.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
53 comments
I’ve tried your method, but still I get Oops, try again. It looks like you didn’t log the length of myCountry to the console.
Try refreshing your browser with CTRL f5 if you still have a problem please post your code on the big window at the bottom of this page.
it works thanks
Yes, refreshing the browser solved the problem. I had the same issue
Thanks. That helped a lot.
THanks
Thanks, thought I was doing something wrong for half an hour. The refresh really worked.
this really works thanks :)
thanks
Thank you for the clarification
Thank for your explanation and now i know why my code can’t pass!
Thanks! That was exactly what I needed!
Thanks a lot this one section frustrated me more than any other section!
Thank you so much, couldn’t find what I did wrong this helped.
Thank you so much for the help!
thank you
// Declare a variable on line 3 called // myCountry and give it a string value. myCountry = “India”
// 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) );
myCountry = “UK” console.log(myCountry.length); console.log(myCountry.substring(0,3) );
Thanks very much, had struggled whilst there is a forum which is very helpful.Almost gave up.
why we write capital C in myCountry , capital A in myAge etc.
thanks alot
Thanks, helped a lot.
Thanks Tony! :) ! It is Called ‘camelCasing’ @MitaliChawla wiki-link: https://en.wikipedia.org/wiki/CamelCase
Many thanks
thanks
Thanks Tony.
omg thank you!
Thanks Tony!
Thanks Tony
Thank you for your help sir :)
you helped alot thank you
thanks
thanks :D
go chinese
keep up the good work leng lee
Thanks
Thank you
Thanks “ tony de araujo “
thanks!!!
I can’t get it to work, keeps tellin me that I have a problem in my synax
hahahhaha
Appreciate it!
Oh my goodness, thank you :) Now I am actually getting it all done haha
Thank you sooooooo much for a crystal clear answer!!!
I’ve been trying but nothing happened then I refreshed my browser so it worked.thanks
THANK YOU SO MUCH! AND DO HELP US FURTHER.
Hey, you’re welcome guys! Glad to be able to help, thanks.
BANANA
i love this
Thank you so much!! For some reason I was putting myCountry.substring(0,8) on the second line when I should have been putting .length. …lol
THANK YOU SO MUCH!!!!!!!!!!!!
Thanks! this helped a bunch
@ctaylo30 I was doing the exact same thing!