Find out if an object or array contains the name "Jeffery". Return true if the collection does, false if it doesn't.
Here's an object and an array you can use for testing:
var names1 = {
name1 : "Jeffery",
name2 : "Sam",
name3 : "Robert",
name4 : "Sarah",
name5 : "Susan",
name6 : "Jolene",
name7 : "Fred",
name8 : "Seth"
};
var names2 = ["Jeffery", "Sam", "Robert", "Sarah", "Susan", "Jolene", "Fred"', "Seth"];
By the way, if you want a true/ false if a certain property exist in an object, then use the in keyword.
For example,
"name2" in names1;
will return true.
No comments:
Post a Comment