diff --git a/Extras/reverse a array.js b/Extras/reverse a array.js index 314622f..42744ff 100644 --- a/Extras/reverse a array.js +++ b/Extras/reverse a array.js @@ -1,20 +1,20 @@ // Using concat() -let arr = [1,2,3,4,5] +let arr = [1, 2, 3, 4, 5] let output = [] -for (i= 1 ; i<=arr.length;i++ ){ -let adam = arr[arr.length-i] -output = output.concat(adam) +for (i = 1; i <= arr.length; i++) { + let adam = arr[arr.length - i] + output = output.concat(adam) } console.log(output) // Using push() -let arr = [1,2,3] +let arr = [1, 2, 3] output = [] -for(i= arr.length-1 ; i>=0; i--){ -output.push(arr[i]) +for (i = arr.length - 1; i >= 0; i--) { + output.push(arr[i]) } console.log(output) @@ -28,7 +28,7 @@ arr.reverse() let string = "Sanskar" let str = "" -for(let x of string){ - str = x+ str +for (let x of string) { + str = x + str } console.log(str)