OneBite.Dev - Coding blog in a bite size

create an array of string in Javascript

Code snippet on how to create an array of string in Javascript

  var animals = ["Lion", "Tiger", "Elephant", "Giraffe"];

This code creates an array called “animals” which stores 4 elements: “Lion”, “Tiger”, “Elephant”, and “Giraffe”. The elements are separated by commas and placed within square brackets. The keyword “var” is used to declare a variable which stores the data. The semicolon at the end of the line is used to indicate that the statement is complete.

javascript