JSFiddle - React, Tailwind, and code Playground
JavaScript
var map, errors, result;
errors = new Map();
errors.set(NaN, "That was not a number!");
errors.set(Infinity, "That was infinity!");
[
1 + 2,
1/0,
1/"foo",
].forEach(function (result) {
if (errors.has(result)) {
console.log(errors.get(result));
} else {
console.log("The result was", result);
}
});