Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Soal No. 1 (Callback Baca Buku)
- //===============================
- console.log("//Soal No. 1 (Callback Baca Buku)");
- console.log("//===============================");
- // di index.js
- var readBooks = require('./callback.js')
- var books = [
- {name: 'LOTR', timeSpent: 3000},
- {name: 'Fidas', timeSpent: 2000},
- {name: 'Kalkulus', timeSpent: 4000}
- ]
- // Tulis code untuk memanggil function readBooks di sini
- var time=10000
- var i=0;
- function letsread(time,books){
- if(time>0 && i<books.length)
- readBooks(time,books[i],function(sisaWaktu){
- time=sisaWaktu;
- i++;
- letsread(time,books)
- })
- }
- letsread(time,books)
Add Comment
Please, Sign In to add comment