Wednesday, September 21, 2022

Array.Find() Return first bigger NUMBER

<!DOCTYPE html>

<html>

<body>

<h2>JavaScript Array.find()</h2>

<p id="demo"></p>

<script>

const numbers = [4, 9, 16, 25, 29];

let first = numbers.find(myFunction);

document.getElementById("demo").innerHTML = "First number over 18 is " + first;

function myFunction(value, index, array) {

  return value > 18;

}

</script>

</body>

</html>




No comments:

Post a Comment

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.