You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two int values, return whichever value is larger. However if the two values have the same remainder when divided by 5, then the return the smaller value. However, in all cases, if the two values are the same, return 0. Note: the % "mod" operator computes the remainder, e.g. 7 % 5 is 2.
*/
// Evan Genest, 4/2019, twitter@mistergenest
let maxMod5 = (a, b)=>{
let modDiff = a % 5 - b % 5;
modDiff = Boolean(modDiff);
try {
if (a === b){
return 0;
} else if (!modDiff){
return [a, b].reduce( (a, b)=>{return(a > b)? b : a});
} else if (modDiff){
return [a, b].reduce( (a, b)=>{return(a > b)? a : b});