combining javascript variables into an array -
I know this is a simple question, but I am new and I can not understand it. I am trying to combine two variables into one array. I want to add var word1 and var word2 to create var new 1. What is the proper way to do this?
var word1 = 'hello' var word 2 = 'good' var newArray = ['hello', 'good']
You can use, do:
var word1 = 'hello'; Var word2 = 'good'; Var arr = []; Arr.push (word1, word2); Console.log (arrive); // ["Hello", "Good"]
Comments
Post a Comment