Skip to content

How to change prompt input to upper or lower case in JS? #603

@Rupanwita

Description

@Rupanwita

I created an array called guestList and the first letter of each name is in uppercase. However, when in the prompt, I am typing the same name but all letters in lower case, I'm not getting the desired results as given in the code, despite changing the guest variable to (.toLowerCase();) .. how to fix it?

var guestList = ["Jack", "Jay", "Jim", "John", "Joseph"];
alert("HEL0000, thanks for dropping by. Click 'OKAY' to check if you're on the invite list!");
var guest = prompt("Enter your name here");
guest.toLowerCase();
if (guestList.includes(guest)) {
alert("Welcome to the party!! 14 Feb, 8PM, sharp");
}
else {
alert("Sorry, may be next time!")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions