DAY -9
// In javascript is a dianamic typeing so will given any datatype in a array and size is not fixed
//example :
const arr = [10,vic,20,30,40];
//How print the array with different method
 //first step : console.log(arr);//full arr data
        //secound : consle.log(arr[2]);//perticulor index data
//using WHILE loop :
const arr =[20,46,66,12,33 ]
        let i = 0
        while(i<5){
            console.log(arr[i]);
            i++;
        }//output : 20,46,66,12,33
USING FOR LOOP
 for(i = 0;i<arr.length;i++){
            console.log(arr[i]); 
        }//output : 20,46,66,12,33
using for-in loop 
for in loop will given the index
 for(let array in arr){
            console.log(array);// show the index 
            console.log(arr[array]);//show the index value
             }//output : 0 1 2 3 4 
             //output : 20,46,66,12,33
//for of loop 
//for of will given the index value
for(let mar of arr){
    console.log(mar);
}//output:  20,46,66,12,33
//foreach loop
//foreach is called a callbackfuction calling statement
//foreach using function
 arr.forEach(printmark);
    function printmark(arr) {
        console.log(arr);
        }
//foreach with function 
//arroy function is not a callback function .because arroy function is a similified of function only
//foreach only runs forword only not backword
arr.forEach(marks => {console.log(marks)
    });///output:  20,46,66,12,33
 

 
    
Top comments (0)