helper.js:
export const getLesserEvil = (threat1, threat2) => {
if (threat1 > threat2) {
return threat2;
} else {
return threat1;
}
}
solution.js:
import { getLesserEvil } from './helper.js';
const globalWarming = {
description: 'Global warming risk',
evilFactor: 10,
}
const aiThreat = {
description: 'The AI threat to humanity',
evilFactor: 1,
}
const globalPandemic = {
description: 'Mass extinction from the global pandemic',
evilFactor: 3,
}
console.log(getLesserEvil(globalWarming.evilFactor, globalPandemic.evilFactor));
console.log(getLesserEvil(aiThreat.evilFactor, globalPandemic.evilFactor));