Adding some small code challenges + some interesting functions

This commit is contained in:
gauvainboiche
2025-07-11 23:44:51 +02:00
parent 548360c345
commit abe38843b3
4 changed files with 108 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
// Write your code here:
// the method .reverse() does it but is NOT allowed here
function reverseArray(array) {
let newArray = [];
for (const element of array) {
newArray.unshift(element); // this will put every read element FIRST in the array
}
return newArray;
}
const sentence = ['sense.','make', 'all', 'will', 'This'];
console.log(reverseArray(sentence))
// Should print ['This', 'will', 'all', 'make', 'sense.'];