Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onlineEducation(input) {
- let onlineStudents = 0;
- let onsiteStudents = 0;
- let educationForm;
- let studentCount;
- for (let i = 0; i < 6; i += 2) {
- educationForm = input[i].toLowerCase();
- studentCount = Number(input[i + 1]);
- if (educationForm === "online") {
- onlineStudents += studentCount;
- } else {
- onsiteStudents += studentCount;
- }
- }
- if (onsiteStudents > 600) {
- onlineStudents += onsiteStudents - 600;
- onsiteStudents = 600;
- }
- console.log(`Online students: ${onlineStudents}`);
- console.log(`Onsite students: ${onsiteStudents}`);
- console.log(`Total students: ${onlineStudents + onsiteStudents}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement