25/28 length not printed although it is


#1

hear is my code please help me to know my problem t coz the answer is right bt program suggests otherwise

var mycountry="Heaven";
console.log( mycountry
mycountry=mycountry.substring(0,3);
console.log(mycountry );

25/28 Javascript: more variable practise
#2

please help me wth ths code, i have tried urs n its nt working..here is mine


#3

Ok this looks pretty close to it but there still are some bugs in it:

First of all your missing a ")" at the first console.log.
Then its myCountry not mycountry this isn't an error in general as you are free to name your variables as you like (if you keep it consistently) but the test function seems to rely on the names in the instructions so often it is necessary to stick to them. And last but not least there you need to print the length of myCountry to the screen so maybe replace the first console.log with one that logs the length.

And after this I still get an error although the code should by now be correct... I'm keep researching and answer this one later.

PS: What works is getting rid of this line:

mycountry=mycountry.substring(0,3);

and instead console.log(mycountry.substring(0,3)); but this is not an error or mistake of any kind so I'm a bit confused that it is not working with it.


#4

thanks it has worked i too was confused why the code wasnt working although the results were right but i did lyk u said,i've eliminated myCountry=myCountry.substring(0,3); and added console.log(mycountry.substring(0,3)); thanks alot


#5

can you please explain the length aspect again


#6

What do you mean? getting the length? simple add .length to a string e.g. "test".length is 4. Or why you get the error? Seems like there was a change and now it is expected that the variable has always the same length :frowning: