Skip to content

Instantly share code, notes, and snippets.

@AsadSaleh
Created January 18, 2023 14:59
Show Gist options
  • Save AsadSaleh/622923deb2aedd05d55d575b46848315 to your computer and use it in GitHub Desktop.
Save AsadSaleh/622923deb2aedd05d55d575b46848315 to your computer and use it in GitHub Desktop.
gas pollll
// 1. Buat fungsi "calculateDiscountedPrice" yang menerima number, lalu mengembalikan number
// dengan value yang sudah dipotong 20% dari harga aslinya.
function calculateDiscountedPrice(inputNumber) {
return; // todo
}
// 2. Buat fungsi "convertIntoDiscountedItem" yang menerima input berbentuk { name:string, price:number }
// lalu menghasilkan output { name:string, price:number } (sama) dengan property price-nya dipotong 20%
function convertIntoDiscountedItem(inputObj) {
return; //todo
}
// 3. Nah, sekarang ubah "arrayOfItems" dibawah ini menjadi "discountedArrayOfItems" baru dengan
// harga yang sudah di diskon 20%.
// Tips: Gunakan Array.map.
const arrayOfItems = [
{
name: "MG Gundam Barbatos",
price: 1_000_000,
},
{
name: "MG Gundam Wing Ver.Ka",
price: 1_200_000,
},
{
name: "MG Gundam Dynames",
price: 700_000,
},
];
const discountedArrayOfItems = []; // todo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment