OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why does return not work here but the console.log() shows the correct result?

  • Thread starter Thread starter KevinBacker
  • Start date Start date
K

KevinBacker

Guest
Code:
function findvalue(arr,num){
const arr1 = arr.find((el) => el === num)
const arr2 = arr1? true: "Not found";
 //console.log(arr2)
return arr2
}

console.log(findvalue([false, "7", null],7)

The function suppose to return true if the num would be found among one of the elements of array, otherwise return the string "Not found"

<pre><code>function findvalue(arr,num){
const arr1 = arr.find((el) => el === num)
const arr2 = arr1? true: "Not found";
//console.log(arr2)
return arr2
}

console.log(findvalue([false, "7", null],7)
</code></pre>
<p>The function suppose to return true if the num would be found among one of the elements of array, otherwise return the string "Not found"</p>
 
Top