Intermediate Algorithm Scripting - Wherefore art thou

So recently i have been playing around a little with the .includes() and .indexOf() and .hasOwnProperty() and what i have seen is that if it does not directly ask us to return the index of elem, that .includes() works for returning the correct answer most of the time. Is the .hasOwnProperty() for when we just want one element back instead of multiple like .includes()? Also if im understanding it correctly .indexOf() can just be used to check if an elem is present just like both the other methods right? i find myself getting lost in differentiating the times when i should use one or the other

Your code so far

function whatIsInAName(collection, source) {
  let srcKeys = Object.keys(source)

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Wherefore art thou

Link to the challenge:

for example saying return !arr1.includes(elem) instead of saying return arr1.indexOf(elem) === -1/////// sorry not sure how accurate of an example that is

Thank you Randell! :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.