JavaScript Lesson 25 I need your help


#1

Hi!
I have a problem

// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = "Poland";
// Use console.log to print out the length of the variable myCountry.
console.log("myCountry".length);
console.log("myCountry".substring(0,9));
// Use console.log to print out the first three letters of myCountry.
console.log("myCountry".substring(0,3));

What is wrong here? Help!!
Thanks a lot in advance!


#2

It's the variable you declared, you are not supposed to put quotes around the variable when you use it.


#3

Thanks for your help! I did it!:smile:


#4

// Déclarez une variable sur la ligne 3 appelée
// monPays et donnez lui pour valeur une chaîne de caractères.
var monPays = "La France";

// Utilisez console.log pour afficher la longueur de la variable monPays.
console.log (monPays.length);

//Utilisez console.log pour afficher les trois premières lettres de monPays.
console.log (monPays.substring (0 , 3);

peux tu me dire ce qui ne va pas dans mon code stp ?


#5

can anyone help me with this one please. The screen to the right returns the correct value but its still wrong and i cant work out why?

var myCountry = "England";
console.log(myCountry);
console.log(myCountry.substring(0,3));


#6

That should return "Engl", what are you trying for? ENG? Then it would be

console.log(myCountry.substring(0,2));

Since arrays work from 0 and up.