hotmail

Report a typo

Which of the following is a proper way to find out if a string ends with @hotmail.com?

A)

let userEmail = '[email protected]';
if (userEmail.endswith('@hotmail.com')) {
    console.log(true);
} else {
    console.log(false);
}

B)

let userEmail = '[email protected]';
if (userEmail.startsWith('@hotmail.com')) {
    console.log(true);
} else {
    console.log(false);
}

C)

let userEmail = '[email protected]';
if (userEmail.indexOf('@hotmail.com') == userEmail.length - 1) {
    console.log(true);
} else {
    console.log(false);
}

D)

let userEmail = '[email protected]';
if (userEmail.endsWith('@hotmail.com')) {
    console.log(true);
} else {
    console.log(false);
}
Select one option from the list
___

Create a free account to access the full topic