Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
untitled notebook
node v14.20.1
version:
1.0.0
endpoint
share
tweet
function insertAtBegginingOfAnArray(arr, num) { if(arr.length === 0) return 0; for(let i = arr.length - 1; i >= 0; i--) { arr[i+1] = arr[i]; } arr[0] = num; return arr; } console.log(insertAtBegginingOfAnArray([23, 45, 56, 7, 99, 10], 11))
Loading…
no comments
sign in
to comment