Hello (<-- two spaces)
World
Hello
World
Hello (<-- two spaces)
World
Hello
World
//given an array | |
const prices = [12, 50, 223, 59, 30] | |
//1. FOR , the old shcool way | |
for (let i = 0 ; i < prices.lenght ; i++) { | |
//process here | |
console.log(prices[i]); | |
} | |
//2. WHILE |
//So, spread operator (...) is mainly used to combine (concatenate) multiple arrays or objects in javascript. | |
//here are some arrays | |
const yearsOne = [2010,2015,2020,2025,2030]; | |
const yearsTwo = [2013,2017,2022,2027,2032]; | |
//first way, simply combined them in an array, separated by a comma | |
const combinedYears = [...yearsOne, ...yearsTwo]; | |
console.log(combinedYears) | |
//output: [2010, 2015, 2020, 2025, 2030, 2013, 2017, 2022, 2027, 2032] |