Created
January 18, 2023 13:12
-
-
Save AsadSaleh/1f05c2cba8acfba4b2b212b4594aea2a to your computer and use it in GitHub Desktop.
Soal latihan JavaScript!!!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Ubah data ini menjadi number | |
const stringNumber = "1285"; | |
// ππππππ Ubah code di bawah ini | |
const number = 0; | |
// ππππππ Ubah code di atas ini | |
console.log(number === 1285 ? "Bener" : "Salah"); | |
// 2. Apa hasil console.log di bawah? | |
const person = { | |
name: "Fulan", | |
age: 20, | |
}; | |
let bisaBikinSIM = false; | |
if (person.age >= 17) { | |
bisaBikinSIM = true; | |
} | |
console.log("bisa bikin sim kah? ", bisaBikinSIM); // π ini apa? | |
// 3. Ubah data dibawah menjadi [1, 4, 9, 16, 25, 36, 49, 64, 81] | |
const arrayOfNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
// ππππππ Ubah code di bawah ini | |
const hasil = []; | |
// ππππππ Ubah code di atas ini | |
console.log("Ini hasil: ", hasil); | |
// 4. Ubah data di bawah menjadi array of object dengan property { "name", "basePrice" } | |
// dimana "name" adalah nama yang ada di arrayOfNames, dan "basePrice" di set menjadi 10000. | |
const arrayOfNames = ["Sabun", "Beras", "Susu", "Gula", "Tepung"]; | |
// ππππππ Ubah code di bawah ini | |
const arrayOfItems = []; | |
// ππππππ Ubah code di atas ini | |
console.log("Ini arrayOfItems: ", arrayOfItems); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment