Question: 2 . Find the First Prime Number in an array: Write a JavaScript function that takes an array of numbers as input and finds the
Find the First Prime Number in an array:
Write a JavaScript function that takes an array of numbers as input and finds the first prime number in the array using a for loop. Use the break statement to exit the loop once the first prime number is found.
If a prime number is found, print it to the console using console.log and stop searching.
If the number is not prime, use the continue statement to skip to the next number in the array.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
