Help substring java script


#1

am currently learning java script. am on lesson 23.
the interperer keeps saying wrong substring for january and am sure the substring is righ. pls helpt


#2

Hi @bitace94944

Show us your code :relaxed:


#3

the code
// Use console.log( ) to print out the substrings.
// Here is an example of the 1st to 4th letter of "JavaScript":
// console.log("JavaScript".substring(0,4));
console.log("january".substring(0,3));
console.log("Melbourne is great".substring(0,13));
console.log("Hamburgers".substring(3,11));


#4

Well your code is rigth, you have to do know what the substring() method extracts between "start" and "end", not including "end" itself.

So in your code

console.log("january".substring(0,3));

will return

jan

because index[3] of "january" is "u" and it's not include you know ?


#5

Hi buddy ,

I too faced with the same problem and finally solved it !!
Make sure that the 'J in January is uppercase when entered in console.log
console.log('January'.substring(0,3));

Make sure that the 'M' in Melbourne is uppercase when entered in console.log
console.log('Melbourne is great'.substring(0,12));

Make sure that the 'H' in Hamburgers is uppercase when entered in console.log
console.log('Hamburgers'.substring(3,10));

Follow this and you will successfully complete this substring practice module..

Good Luck!!!


#6

why is "January".substring(0,3); wrong?

These are the instructions:
Using console.log, on three separate lines, print out the substrings for the following strings.

a. "Jan" in "January"

Thanks