Substring


#1

hi im trying to learn how to code but this substringing has got me stumped lol anyone got any pointers.


#2

@d4rb,

Reference::

google search
== the book ==
javascript substring() site:developer.mozilla.org

== discussions / opinions ==
javascript substring() site:stackoverflow.com


#3

This is final code:
"wonderful day".substring(3, 7);


#4

but shouldn't the 7th letter equal the number 6 instead of 7 ??


#5

.substring(3, 7) takes indices 3, 4, 5, and 6. It is a bit confusing! :slightly_smiling:


#6

In programming, numbers start at zero. So in substring, say you want to cut out "Goo" in "Google":
"Google".substring(0, 3);

Take a look here if you want to learn more: http://www.w3schools.com/jsref/jsref_substring.asp

If you have any other questions, feel free to reply. :slightly_smiling:


#7

How are you doing now @d4rb?


#8

Probably used an hour trying to figure out why my code didnt work. Had an uppercase "W" in wonderful


#9

I still don't get it. My code
console.log("January").substring(0,2));
console.log("Melbourne is great").substring(0,11));
console.log("Hamburgers").substring(3,8));


#10

You can't use .substring() on a function like console.log().

Read earlier posts, and figure out your problem.