DEV Community

KISHAN RAMLAKHAN NISHAD
KISHAN RAMLAKHAN NISHAD

Posted on

Some commonly asked JavaScript array-related interview questions along with their answers

  1. How do you find the largest number in an array? Question: Write a function to find the largest number in an array. Answer:
function findLargestNumber(arr) {
  return Math.max(...arr);
}
console.log(findLargestNumber([3, 5, 7, 2, 8])); // Output: 8

Enter fullscreen mode Exit fullscreen mode

Top comments (0)