Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
updated
  • Loading branch information
Kevin Himawan Hie authored and Kevin Himawan Hie committed Feb 5, 2018
commit d70f877f8570d177bca5ed9d762661f243d1b42f
51 changes: 51 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Tentukan tanggal buka dan tutup
// Buat sebuah object untuk para member
// Lakukan pengulangan untuk print jadwal 1 bulan
// Apabila tanggal habis dibagi 5 tempat fitness tutup
// Buat sebuah array kosong untuk menampung siapa saja yang latihan di hari tersebut

class ProblemSolving{
constructor(jadwal){
this.tanggalBuka = 7
this.jadwalPersons = jadwal
this.jadwal = []
}

setDay(){
for(let i = this.tanggalBuka; i <= 31; i++){
if(i % 5 == 0){
this.jadwal += `Tanggal ${i} : Tempat Fitness Tutup \n`
}else{
let jadwalPerHari = []
jadwal.forEach(function(person) {
if((i - 7) % person.waktu === 0){
jadwalPerHari.push(person.name)
}
});
this.jadwal += `Tanggal ${i} : ${jadwalPerHari.join(", ")} \n`
}
}

return this.jadwal
}
}

let jadwal = [{
name: "Tono",
waktu: 2
},
{
name: "Anton",
waktu: 4
},
{
name: "Budi",
waktu: 5
}]

let soal1 = new ProblemSolving(jadwal)
console.log(soal1.setDay())