Skip to content

Commit

Permalink
proper indent
Browse files Browse the repository at this point in the history
  • Loading branch information
sanskaarz committed Dec 1, 2024
1 parent a040656 commit e92a2d4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Extras/reverse a array.js
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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)

0 comments on commit e92a2d4

Please sign in to comment.