Java script plz reply 23/28


Getting the positioning of substring letter positions is tricky! Let's make sure we really have it nailed down.

Remember that each character in a string is numbered starting from 0. So for the word "hello", The letter h is in position 0, the letter e is in position 1, and so on.

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

a. "Jan" in "January"
b. "Melbourne is" in "Melbourne is great" (note the space!)
c. "burgers" in "Hamburgers"

Here's how to print the first 2 letters of the world "hello":

console.log( "hello".substring(0, 2) );

Replace this line with your code. 
console.log("Jan" in "January");
console.log("Melbourne is" in "Melbourne is great");
console.log("burgers" in "Hamburgers");


Judging by the directions you were given, you just forgot a couple of things...
the ".substring" after your string and the argument after the .substring...

console.log("January".substring(0,3) ); // or maybe 0,2?
= print the first 3 letters of January

Try that and see if it works!


thanks a bunch m8 could you help me on the next on as im stuck i posted it as 23/28 please help


We saw basic math before. The basic math symbols we learned in school work here. Even the order in which the computer understands the math is the same as in school!


( ): control order of operations
* and /: multiplication and division
- and +: subtraction and addition

100/10 evaluates to 10
"Jane".length + 5 evaluates to 9
5*(3+1) evaluates to 20
Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true.
Finish the else statement by printing out the string "Error Error Error" to the console.
There is a lot of left out syntax. The if keyword and the { } after the else keyword are all left out.

Make sure not to delete any of the provided code. It could cause your code to fail!

Oops, try again. It looks like 'Jon' on line 5 was not defined before it was used. This means either you need to define it, 'Jon' is spelled incorrectly or you need quotes around 'Jon'.

("Jon".length * 2 / (2+1) === 3 )
console.log("The answer makes sense!");
console.log("Error Error Error")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.