Created
August 20, 2020 00:58
-
-
Save angelyoung24/2f211f72999b55731288e8079ac07abb to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/civugay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// moveZeros([1, 2, 0, 1, 0, 0, 3, 6]) | |
// [1, 2, 1, 3, 6, 0, 0, 0] | |
// I know, I know, it's not clean code! | |
// I wanted to use array prototype and I had no time to do the problem. | |
// At least I used const and not var | |
const moveZeros = [1, 2, 0, 1, 0, 0, 3, 6]; | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
console.log(moveZeros); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// moveZeros([1, 2, 0, 1, 0, 0, 3, 6]) | |
// [1, 2, 1, 3, 6, 0, 0, 0] | |
// I know, I know, it's not clean code! | |
// I wanted to use array prototype and I had no time to do the problem. | |
// At least I used const and not var | |
const moveZeros = [1, 2, 0, 1, 0, 0, 3, 6]; | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
console.log(moveZeros); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// moveZeros([1, 2, 0, 1, 0, 0, 3, 6]) | |
// [1, 2, 1, 3, 6, 0, 0, 0] | |
// I know, I know, it's not clean code! | |
// I wanted to use array prototype and I had no time to do the problem. | |
// At least I used const and not var | |
const moveZeros = [1, 2, 0, 1, 0, 0, 3, 6]; | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
moveZeros.push(moveZeros.splice(moveZeros.indexOf(0), 1)[0]); | |
console.log(moveZeros); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment