Answers for "how to add variables to an array in javascript"

1

how to add variables to an array

// how to add variables/string/value to an array in Javascript

const addArray = [
  "Hello",
  "My",
  "Name",
  "is"
];

// add/append new value/variable/string to the array
addArray.push("Chetan");

console.log(addArray);
Posted by: Guest on December-27-2021
0

how to add variables to an array in javascript

function addNewArray(newArr){
   newArr.push("Dominic");
   return newArr;
}
//calling a function
addNewArray(newArr["My", "is" ])//Output:["My", "is", "Dominic"]
Posted by: Guest on April-21-2022

Code answers related to "how to add variables to an array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language