помощ за задача Online Education
function onlineEducation([arg1, arg2, arg3, arg4, arg5, arg6]) {
let predForm = arg1
let predNumber = Number(arg2)
let regularForm = arg3
let regularNumber = Number(arg4)
let latestForm = arg5
let latestNumber = Number(arg6)
if(predForm === 'onsite' && regularForm === 'onsite' && latestForm === 'onsite'){
total = predNumber + regularNumber + latestNumber
if(total > 600) {
online = total - 600
console.log("Online students: " + online)
console.log("Onsite students: 600")
} else{
console.log("Online students: 0" )
console.log("Onsite students: " + total)
}
}
else if(predForm === 'onsite' && regularForm === 'onsite'){
predregularNumber = predNumber + regularNumber
if(predregularNumber > 600) {
online_students_count = predregularNumber - 600 + latestNumber
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + latestNumber)
console.log("Onsite students: " + predregularNumber)
}
}
else if(predForm === 'onsite' && latestForm === 'onsite'){
predLatestNumber = predNumber+latestNumber
if(predLatestNumber > 600) {
online_students_count = predLatestNumber - 600 + regularNumber
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + regularNumber)
console.log("Onsite students: " + predLatestNumber)
}
}
else if(regularForm === 'onsite' && latestForm === 'onsite'){
regularlatestNumber = regularNumber + latestNumber
if(regularlatestNumber > 600) {
online_students_count = regularlatestNumber - 600 + predNumber
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + predNumber)
console.log("Onsite students: " + regularlatestNumber)
}
}
else if(predForm === 'onsite') {
online_students_count = regularNumber + latestNumber
if(predNumber > 600) {
online_students_count = predNumber - 600 + online_students_count
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + online_students_count)
console.log("Onsite students: " + predNumber)
}
}
else if(regularForm === 'onsite'){
online_students_count = predNumber + latestNumber
if(regularNumber > 600) {
online_students_count = regularNumber - 600 + online_students_count
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + online_students_count)
console.log("Onsite students: " + regularNumber)
}
}
else{
online_students_count = predNumber + regularNumber
if(latestNumber > 600){
online_students_count = latestNumber - 600 + online_students_count
console.log("Online students: " + online_students_count)
console.log("Onsite students: 600")
} else{
console.log("Online students: " + online_students_count)
console.log("Onsite students: " + latestNumber)
}
}
total_students = predNumber + regularNumber + latestNumber;
console.log("Total students: " + total_students)
}
Благодаря и аз така трябва да се науча да пиша
Здравейте,
Ето и моето решение на задачата: https://pastebin.com/MZsTRnLQ