Check if an Object has a Property (how can I make it work )

Tell us what’s happening:

Your code so far

let users = {
  Alan: {
    age: 27,
    online: true
  Jeff: {
    age: 32,
    online: true
  Sarah: {
    age: 48,
    online: true
  Ryan: {
    age: 19,
    online: true

function isEveryoneHere(obj) {
  // change code below this line
let regex=/^[Alan,Jeff,Sarah,Ryan]/;
  return true;
return false;
  // change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

This exercise wants to use method called hasOwnProperty so I wouldn’t use a regex here.

Use this method to check if all the users exist in the object. Return true if they are, return false if otherwise.

yes…but is my code correct ?
I don’t guess so as I’m not sure about the structure

No, it’s not correct.
You probably wanted to use if statement here instead of forloop.
You can’t use regex like that. Use a test method.
It’s indexOf not IndexOf.
You can’t compare if it’s greater than 0 inside your indexof function. You need to get out of it.

Cheers :slight_smile:

1 Like