Created
January 15, 2019 20:10
-
-
Save Dmitriy-8-Kireev/c082005aa2e09c2480286376ef72b8e8 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
This file contains hidden or 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"> | |
| /** | |
| * Перенос нулей в конец массива | |
| * @param {number[]} input | |
| * @return {number[]} | |
| */ | |
| function zsort(input) { | |
| return [...input.filter(x=>x!==0), ...input.filter(x=>x===0)] | |
| } | |
| // Проверка | |
| console.log(zsort([1, 0, 2, 3, 0, 4, 0])); // [1, 2, 3, 4, 0, 0, 0] | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">/** | |
| * Перенос нулей в конец массива | |
| * @param {number[]} input | |
| * @return {number[]} | |
| */ | |
| function zsort(input) { | |
| return [...input.filter(x=>x!==0), ...input.filter(x=>x===0)] | |
| } | |
| // Проверка | |
| console.log(zsort([1, 0, 2, 3, 0, 4, 0])); // [1, 2, 3, 4, 0, 0, 0]</script></body> | |
| </html> |
This file contains hidden or 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
| /** | |
| * Перенос нулей в конец массива | |
| * @param {number[]} input | |
| * @return {number[]} | |
| */ | |
| function zsort(input) { | |
| return [...input.filter(x=>x!==0), ...input.filter(x=>x===0)] | |
| } | |
| // Проверка | |
| console.log(zsort([1, 0, 2, 3, 0, 4, 0])); // [1, 2, 3, 4, 0, 0, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment