From dfe8f288d7d10615629b819f1a8f709d5e215196 Mon Sep 17 00:00:00 2001
From: shaik fazil basha <93812181+fazil-shaik@users.noreply.github.com>
Date: Tue, 30 Jan 2024 17:33:37 +0530
Subject: [PATCH] Update array.js

implemented the changes by iterating the elements using for and foreach elements
---
 src/data-structures/arrays/array.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/data-structures/arrays/array.js b/src/data-structures/arrays/array.js
index 909ed1da..25f30a3f 100644
--- a/src/data-structures/arrays/array.js
+++ b/src/data-structures/arrays/array.js
@@ -22,6 +22,18 @@ array.splice(4, 2); // array: [0, 2, 5, 1, 7, 4, empty, 3]
 array.splice(1, 0, 111); // at the postion 1, delete 0 elements and insert 111
 //=> array: [2, 111, 5, 1, 9, 6, 7]
 
+//Iterating towards the given elements
+// Using a for loop
+for (let i = 0; i < array.length; i++) {
+  console.log(array[i]);
+}
+
+// Using forEach
+fruits.forEach(function (fruit) {
+  console.log(fruit);
+});
+
+
 // Deleting from the beginning of the array.
 array.shift(); //=> [5, 1, 9, 6, 7]