CoDEVIANT #18 (10/5/20) — Sprinkles on Top!

We want our whipped-cream integer-elements at the end of the array. Doesn’t that look good? I mean it’s diabetes on a cone, but DAYUM.
function moveElementToEnd(array, toMove) {
let arr = []
arr = array.filter(el => {
if(el !== toMove) {
return el
}
})
let counter = array.length - arr.lengthfor(let i = 0; i < counter; i++) {
arr.push(toMove)
}
return arr
}
let arr = []
let arr = []
arr = array.filter(el => {
if(el !== toMove) {
return el
}
})
let counter = array.length - arr.length
for(let i = 0; i < counter; i++) {
arr.push(toMove)
}
return arr
If anyone could correct me on that, that’d be cool.
function moveElementToEnd(array, toMove) {
let soughtValues = []
let otherValues = []
array.forEach(el => {
if(el === toMove) {
soughtValues.push(el)
} else {
otherValues.push(el)
}
})
return otherValues.concat(soughtValues)
}
let soughtValues = []
let otherValues = []
array.forEach(el => {
if(el === toMove) {
soughtValues.push(el)
} else {
otherValues.push(el)
}
})
return otherValues.concat(soughtValues)
function moveElementToEnd(array, toMove) {
let a = 0
let z = array.length - 1

while(a < z) {
while(a < z && array[z] === toMove) {
z --
}

if(array[a] === toMove) {
array[a] = array[z]
array[z] = toMove
}

a++
}
return array
}
let a = 0
let z = array.length - 1
while(a < z) {
while(a < z && array[z] === toMove) {
z--
}

...
}
while(a < z) {
while(a < z && array[z] === toMove) {
z--
}
if(array[a] === toMove) {
array[a] = array[z]
array[z] = toMove
}

}
while(a < z) {
while(a < z && array[z] === toMove) {
z--
}
if(array[a] === toMove) {
array[a] = array[z]
array[z] = toMove
}
a++
}
function moveElementToEnd(array, toMove) {
let a = 0
let z = array.length - 1

while(a < z) {
while(a < z && array[z] === toMove) {
z --
}

if(array[a] === toMove) {
array[a] = array[z]
array[z] = toMove
}

a++
}
return array
}

--

--

--

is a web developer, opera singer, actor, and lover of cats. (adrian-rosales.tech)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Use Cypress to test AWS Amplify Apps with Authentication

【鬼弒訊】▷線上看小鴨完整版~2020《 Host》~看电影完整版 — 1080P

https://youtu.be/fI1_EbPjnYo

Understanding the useState hook in ReactJs

Let’s see

How To Iterate Through Javascript Objects

Migrating Keeps.com to Next.js

React: Building an accessible FAQ component

Image showing an example of FAQs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Rosales

Adrian Rosales

is a web developer, opera singer, actor, and lover of cats. (adrian-rosales.tech)

More from Medium

Setting Up Git for Unity

How To Install HomeBridge on Portainer

Play Soundfonts with Timidity in Ubuntu

Animal Part II: Plastic Forms