CBSE 16. WEB SCRIPTING - JAVA SCRIPT (5 MARKS)

 

24. Finding the Length of an Array

JavaScript

<!DOCTYPE html>

<html>

<head>

<title>Array Length</title>

</head>

<body>

 

<script>

  var fruits = ["apple", "banana", "orange"];

  var length = fruits.length;

  document.write("The array has " + length + " elements.");

</script>

 

</body>

</html>

This finds the number of elements in the fruits array.

No comments:

Post a Comment