Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. const numbers = [102, 101, 1.5, 1, 2, 3, 22, 77, 4, 5, 6, 7];
  2.  
  3. const prices1 = [10, 20, 30, 40, 40, 60];
  4.  
  5. const prices2 = [70, 80, 90, 100];
  6.  
  7. const names = ["Rene", "Tom", "Claire", "Ralph", "Ben"];
  8.  
  9. const colors = ["Red", "Green", "Blue", "Yellow", "Red", "Green Red"];
  10.  
  11. //.map()
  12. //array.map(function(currentValue, index, arr), thisValue)
  13.  
  14. //.forEach()
  15. //array.forEach(function(currentValue, index, arr), thisValue)
  16.  
  17. //.reduce()
  18. //array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
  19.  
  20. //.filter()
  21. //array.filter(function(currentValue, index, arr), thisValue)
  22.  
  23. //.reverse()
  24. //array.reverse()
  25.  
  26. //.concat()
  27. //array1.concat(array2, array3, ..., arrayX)
  28.  
  29. //.join()
  30. //array.join(separator)
  31.  
  32. //.push()
  33. //array.push(item1, item2, ..., itemX)
  34.  
  35. //.pop()
  36. //array.pop()
  37.  
  38. //.slice()
  39. //array.slice(start, end)
  40.  
  41. //.splice()
  42. //array.splice(index, howmany, item1, ....., itemX)
  43.  
  44. //.sort()
  45. //array.sort(compareFunction)
  46.  
  47.  
  48. const cars = [
  49. {
  50. name: "Mercedes",
  51. color: "Grey",
  52. age: 2,
  53. price: 90000
  54. },
  55. {
  56. name: "Opel",
  57. color: "Green",
  58. age: 1,
  59. price: 40000
  60. },
  61. {
  62. name: "VW",
  63. color: "Yellow",
  64. age: 15,
  65. price: 30000
  66. },
  67. {
  68. name: "Audi",
  69. color: "Blue",
  70. age: 3,
  71. price: 60000
  72. },
  73. {
  74. name: "Citroen",
  75. color: "Pink",
  76. age: 11,
  77. price: 40000
  78. },
  79. {
  80. name: "Jaguar",
  81. color: "Orange",
  82. age: 5,
  83. price: 80000
  84. },
  85. {
  86. name: "Ferrari",
  87. color: "Red",
  88. age: 6,
  89. price: 500000
  90. }
  91. ];
  92.  
  93. //1. 20% discount on vehicles older than 10 years
  94. //2. Sort by price
  95. //3. Repaint pink cars to red
  96. //4. Total value of all cars
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement