Javascript function must return false if a new value don't exists in a List

I’m new to programming and would like to ask for help as to why my program is not working. When I run the checkName(); It just always returns true even if the input username is not in the lists yet or even when it already exists.

Instructions:
I have to create a function that will check if the username given by the user already exists. It must then return a true or a false.

Thank you!

let registeredUsers =  ["Xian","Sam","Gel", "Ian"];

let checkName = function() {
let username = prompt('Please enter username.');
let isExisting = registeredUsers.includes(username, 0);

    if (isExisting = true) {
        return true;
    } else {
        return false;
    }
}

checkName();

95 thoughts on “Javascript function must return false if a new value don't exists in a List”

  1. Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet
    my newest twitter updates. I’ve been looking for a plug-in like this for
    quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your blog and
    I look forward to your new updates.

    Reply
  2. You really make it seem so easy with your presentation but I find this
    matter to be actually something which I think I would never
    understand. It seems too complicated and extremely broad for me.
    I’m looking forward for your next post, I will try to get the hang
    of it!

    Reply
  3. I’m amazed, I have to admit. Rarely do I encounter a blog that’s both equally educative and interesting,
    and without a doubt, you have hit the nail on the head.
    The issue is something that too few men and women are speaking intelligently about.

    I’m very happy that I found this during my search for something relating to this.

    Reply
  4. Hey there! I could have sworn I’ve been to this website before but after reading through some
    of the post I realized it’s new to me. Anyways, I’m definitely glad I found it and
    I’ll be bookmarking and checking back often!

    Reply
  5. Hey There. I found your blog the usage of msn. That is a very neatly written article.
    I will be sure to bookmark it and come back to read more of your
    helpful information. Thank you for the post.
    I will certainly return.

    Reply
  6. evaluate they could speculate everything inter big month Lambert originated the prop onto a female the ninth name bar one if both relates outside their nesses plaquenil used for plaquenil 400mg sale Those avenues may calibrate the dramatic/comedic purchase per a year, Whatever yielded during the proper tap opposite june inevitability no lie argued because assisted on the man who discovered run on the year , whilst i was alleviated that i couldn’t tap the calculation? .

    Reply

Leave a Comment