Skip to content

Instantly share code, notes, and snippets.

@luan0ap
Last active May 31, 2022 18:51
Show Gist options
  • Save luan0ap/6d355abcf5fed4455a1f72298face1bd to your computer and use it in GitHub Desktop.
Save luan0ap/6d355abcf5fed4455a1f72298face1bd to your computer and use it in GitHub Desktop.
Create a new array filled with zeros
/**
* 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