Small JavaScript practice tasks covering array methods, iteration, filtering, sorting, shuffling, and deduplication.
Open index.html and check the browser console to see outputs from each task.
- A sub task in loops & arrays
sumOfTripledEvens(array)– kept original logic as written in the exercise code notes.
- Camelize (two versions)
camelize(str)– manual split/capitalize/joincamelizeAlt(str)– alternative withmap
- filterRange (non-mutating)
filterRange(arr, a, b)– returns values in[a, b]without modifying the original array (uses a separateresult_filterRangearray)
- filterRangeInPlace (mutating)
filterRangeInPlace(arr, a, b)– removes values outside[a, b]from the same array
- Sort (decreasing)
sortDecreasingOrder(arr)– sorts numbers descending
- Copy & sort
copySorted(arr)– returns a sorted copy using moderntoSorted()(original array remains unchanged)
- Shuffle
shuffleArray(array)– simplesort(() => Math.random() - 0.5)demo
- unique
unique(arr)– returns a new array with duplicates removed (preserves first occurrence order)
- Clone or download the repo.
- Open
index.htmlin your browser. - Open the DevTools Console to see outputs.
Note: This project uses modern JavaScript features like
Array.prototype.toSorted(). Use a recent browser (Chrome/Edge/Firefox/Safari) for best compatibility.