Last active
May 31, 2022 18:51
-
-
Save luan0ap/6d355abcf5fed4455a1f72298face1bd to your computer and use it in GitHub Desktop.
Create a new array filled with zeros
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
/** | |
* Fill an array with zeros | |
* @param n - expected array length | |
* @returns Array | |
*/ | |
const filledEmptyArray = (n) => { | |
const zerosArray = new Array(n) | |
for (let i=0; i<n; ++i) { | |
zerosArray[i] = 0 | |
} | |
return zerosArray | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment