Help please , what is wrong in this code


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/4?curriculum_id=506324b3a7dffd00020bf661


could you please tell me what is my problem?

Oops, try again. Remember how to check the value of an element in an array? You simply do arrayName[i]. Check the Hint if you need help!

var text = "hi, my name is mahmoud";
var myName = "mahmoud";
var hits = [];
for(i = 0; i < text.length; i++)
console.log(i);
if (i) {
    console.log();
}
else {
    var myName = "mahmoud";
    }
    console.log();


#2

Read the hint in the exercise. They give you a sample code to use:

Remember, an if statement looks like this:

if (some condition) {
    // Do something!
}
You can check the ith letter of text like so:

// Assuming your name starts with 'E'
if (text[i] === 'E') {
    // Do something!
}

This if statement if (text[i]=== 'E') means if there is a capital E in the text, then the if code block will execute. So this exercise wants you to write an if statement with a condition that will execute if it comes across the first letter in your myName variable, which is 'm'. Nothing more, nothing less. You don't need to log anything to the console or an else statement. If anything is unclear, just ask. We're here to help.


#3

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