26. JavaScript I'm stuck


#1

This is what I have I don't know what's wrong. It keeps saying "It looks like you didn't log the first two letters of your name to the console!"

  1. // On line 2, declare a variable myName and give it your name.
  2. console.log(myName = "Dylan");
  3. // On line 4, use console.log to print out the myName variable.
  4. console.log(myName);
  5. // On line 7, change the value of myName to be just the first 2
  6. // letters of your name.
  7. console.log(myName = "Dylan".substring(0,2));
  8. // On line 9, use console.log to print out the myName variable.
  9. console.log(myName);

#2

in line 7, instead of using a string literal, try using the variable where you already stored your name


#4

@redturtle36, did you read instruction to the lesson??

how to create a variable:
var myAge = "Thirty";

So, to declare a variable myName you need:

var myName = "Dylan";

Next:

//On line 7, change the value of myName to be just the first 2
// letters of your name.
console.log(myName = "Dylan".substring(0,2));

Should be:

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

#5

2 posts were split to a new topic: 8. I'm stuck and there is not much for instructions


#6

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