Skip to content

Instantly share code, notes, and snippets.

@appoll
Created November 23, 2022 18:02
Show Gist options
  • Save appoll/08e5894a75fc676d61d99799cb3a3c5b to your computer and use it in GitHub Desktop.
Save appoll/08e5894a75fc676d61d99799cb3a3c5b to your computer and use it in GitHub Desktop.
// E0. Increase all prices larger than 2000 with 10%;
prices = [120, 1600, 2400, 2800]
for (i=0; i < prices.length; i++){
}
console.log("Result: " + prices);
// 120, 1600, 2640, 3080
// E1
// Start with 2 hardcoded arrays, e.g. prices1 & prices2
// Calculate a third array that contains all the elements
// in the first two arrays.
prices1 = [12, 16, 24, 28]
prices2 = [1, 1, 1, 1]
allPrices = []
for (i=0; i < prices1.length; i++){
// ..
}
// Hint: another for loop?
console.log("Result: " + allPrices);
// [12, 16, 24, 28, 1, 1, 1, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment