You are viewing a single comment's thread. Return to all comments →
Javascript :-
let n1 = []; let update = items.map((item) => { if (item < 38) { n1.push(item); } else { let nextMultipleBy5 = Math.round(item / 5); if (nextMultipleBy5 * 5 > item) { n1.push(Math.abs(nextMultipleBy5 * 5 - item) < 3 ? nextMultipleBy5 * 5 : item); } else { n1.push(Math.abs((nextMultipleBy5 + 1) * 5 - item) < 3 ? (nextMultipleBy5 + 1) * 5 : item); } } }); console.log(n1); return n1;
Seems like cookies are disabled on this browser, please enable them to open this website
Grading Students
You are viewing a single comment's thread. Return to all comments →
Javascript :-
let n1 = []; let update = items.map((item) => { if (item < 38) { n1.push(item); } else { let nextMultipleBy5 = Math.round(item / 5); if (nextMultipleBy5 * 5 > item) { n1.push(Math.abs(nextMultipleBy5 * 5 - item) < 3 ? nextMultipleBy5 * 5 : item); } else { n1.push(Math.abs((nextMultipleBy5 + 1) * 5 - item) < 3 ? (nextMultipleBy5 + 1) * 5 : item); } } }); console.log(n1); return n1;