Substrings


#1

I'm stuck in solving a print out using console.log for "jan in "january" string.Thanks


#2

"january".substring(0, 3);

You pick up the first three letters of the string (starting at 0, not 1), The second param in the substring function is excluded (so, you will be getting letters in the 0, 1 and 2 positions).


#3

Hi @filex24

I'm agree with @arccoder77254 , you have to do know what the substring() method extracts between "start" and "end", and not including "end" itself.

 console.log("january".substring(0,3)); //will return jan

Reason : index[3] of "january" is "u" and it's not include.

Hold on :wink:


#4

Hi ,

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!!!


#5

Thank so much. Dude, I was staring at the editor for 10 minutes trying to figure out what did wrong! :grinning: :grinning: :grinning: