Introduction to JavaScript Arrays

    // create an array
    const array = [] // empty array
    
    // create an array of colors
    const colors = ['blue', 'green', 'yellow', 'red', 'orange']
    
    // create an array of numbers
    const numbers = [1, 17, 8, 24]
    
    // create a groceries list
    const groceries = ['Apples', 'Milk', 'Ice Cream', 'Bread']
    
    console.log(colors[0])
    console.log(colors[1])
    const groceries = ['Apples', 'Milk']
    
    groceries.push('Bread')
    
    groceries.push('Yogurt', 'Bananas')
    
    
    groceries.pop()
    
    groceries.shift()
    
    groceries.unshift('Carrots')
    
    groceries.unshift('Flour', 'Butter')
    const colors = ['red', 'yellow', 'Purple', 'blue', 'green', 'orange']
    
    colors.sort(function (a, b) {
      return a.toLowerCase() < b.toLowerCase() ? -1 : 1;
    })
    
    colors.reverse()
    
    console.log(colors)
    
    const numbers = [1, 20, 4, 100]
    
    numbers.sort(function (a, b) {
      return a - b
    const primary = ['red', 'blue', 'yellow']
    const secondary = ['purple', 'green', 'orange']
    
    const colors = [...primary, ...secondary]
    
    console.log(primary)
    console.log(secondary)
    
    console.log(colors)
A basic introduction to how to use arrays in JavaScript