You only need one

Lee·2022년 8월 16일

Algorithm

목록 보기
72/92
post-thumbnail

❓ You only need one

Q. You will be given an array a and a value x. All you need to do is check whether the provided array contains the value.

Array can contain numbers or strings. X can be either.

Return true if the array contains the value, false if not.

✔ Solution

//#my solution
function check(a, x) {
  // your code here
  return a.includes(x)
}


//#other solution
function check(a,x){
    return (a.filter(v=>v==x)).length > 0
}
profile
Lee

0개의 댓글