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

 

27. Reversing an Array

JavaScript

<!DOCTYPE html>

<html>

<head>

<title>Reversing Array</title>

</head>

<body>

 

<script>

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

  fruits.reverse();

  document.write(fruits);

</script>

 

</body>

</html>

This reverses the order of the elements in the fruits array.

No comments:

Post a Comment