Skip to content

Instantly share code, notes, and snippets.

@Doko-Demo-Doa
Created April 29, 2023 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Doko-Demo-Doa/b35bbf12f4867c013655542b93407d29 to your computer and use it in GitHub Desktop.
Save Doko-Demo-Doa/b35bbf12f4867c013655542b93407d29 to your computer and use it in GitHub Desktop.
Array Filtering (also modify the original array)
function modify(arr) {
let i = 0
while (i < arr.length) {
if (isNaN(arr[i])) {
arr.splice(i, 1)
--i
} else {
i++
}
}
return arr
}
var arrr = [1, 2, 'b', 'h', 3, 4, 12]
modify(arrr)
console.log(arrr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment