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

Pros and Cons of JavaScript for Machine Learning

React Tutorial- Tic-Tac-Toe

Building A Simple Reddit Client Web by Angular X & RxJS 6 — Chapter 1

Java Optional

Javascript Closures Made Simple — Part 1

Blue Ocean Day 4

Build Offline Capable Apps With React Native and Redux Offline

Use Python or JavaScript to Send Your Events and Logs to Telegram via their Chatbot API

Publish your events and logs to Telegram

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

Global Brands With Exemplary DEI Practices! — KNOLSKAPE

WHO’S MINDING THE STORE

#fadybouaz