modify array elements javascript
Using a FOR loop, write a function addNumber which adds the argument n to each
number in the array arr and returns the updated arr:
const addNumber=(arr, n)=>{
let arr1=[];
for(let i=0;i<Math.max(arr.length);i++){
arr1.push((arr[i]||0)+n)
}
return arr1;
}
console.log(addNumber([4, 5, 6], 7)); // expected log [11, 12, 13]let newArray = oldArray.map(funcToEachElem);
Also in JavaScript:
- how to verify timestamp format in javascript
- higher order functions javascript
- react hook s
- remove a class after 100 milliseconds jquery
- how to delete node_modules
- express how to access ajax post data
- insert into mongodb node js
- js return undefined on ReferenceError
- js remove form object by key
- expressjs cheat sheet
- fizzbuzz js
- store console.timeEnd in variable js
- react admin newrecords.foreach is not a function
- react how to pass the input target value
- jquery create element
- mongodb distancefield to kms
- how to add a variable in js
- webpack Module not found: Error: Can't resolve '../
- javascript set variable inline
- first n elements of array js
- vuejs my chart load before fetch data
- react disable eslint errors
- event module in node js
- node js store values in file