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
| const fs = require('fs'); | |
| /** | |
| Tiga operasi menghapus file di bawah ini, walaupun disusun berurutan | |
| tetapi belum tentu selesainya berurutan dari operasi 1 sampai operasi 3. | |
| */ | |
| // Operasi 1 | |
| fs.unlink('/file-one', function(err) { | |
| console.log('file one is deleted'); |
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
| var sampleData = [1, 2, 3, 4, 5]; | |
| /* | |
| Buat fungsi yang mengakumulasi keseluruhan elemen dalam Array. | |
| Hasil yang diharapkan 15 | |
| */ | |
| // Menggunakan perulangan for | |
| function denganPerulangan(data) { | |
| var result = 0; |
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
| var sampleData = [1, 2, 3, 4, 5]; | |
| /* | |
| Buat fungsi yang menghasilkan Array yang isinya hanya bilangan genap. | |
| Hasil yang diharapkan [2, 4] | |
| */ | |
| // Menggunakan perulangan for | |
| function denganPerulangan(data) { | |
| var expectedResult = []; |
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
| var sampleData = [1, 2, 3, 4, 5]; | |
| /* | |
| Buat fungsi yang mengalikan setiap elemen dengan angka 2. | |
| Hasil yang diharapkan [2, 4, 6, 8, 10] | |
| */ | |
| // Menggunakan perulangan for | |
| function denganPerulangan(data) { | |
| var expectedResult = []; |
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
| // Contoh higher-order function | |
| function salam(time) { | |
| return function(userName) { | |
| return time + " " + userName; | |
| } | |
| } | |
| // Jika dipanggil langsung | |
| salam("Selamat pagi")("Asep"); // Hasilnya: "Selamat pagi Asep" |
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
| (ns sample.core | |
| (:require [cljsjs.react] | |
| [reagent.core :as reagent :refer [atom]])) | |
| (defn text-editor | |
| "Text editor for static blog." | |
| [] | |
| (let [grid (aget js/ReactBootstrap "Grid") | |
| row (aget js/ReactBootstrap "Row") | |
| col (aget js/ReactBootstrap "Col")] |
NewerOlder