I want a function to take two parameters, and if they are both numbers to tell me which is bigger. i also want it to give a nice output if they are some of them are not numbers (beacause it won't be able to calculate it anyway).
I've got to the point where it is able to handle int, but not floats. it got over my head and I'm wondering what would be the best practice to write that down.
here is what I got so far;
var iamanumbergenius = function(a, b) {
if (Number.isInteger(a) && Number.isInteger(b)) {
if (a > b) {
console.log('first is greater');
} else if (b > a) {
console.log('second is greater');
} else {
console.log('equality is the answer');
}
} else { console.log('i only like nums'); }
}
sorry for ugly code, brought right out of chrome dev tools, where there's no such thing as hitting the enter with out anxiety XD
pretty sure I'm missing some method or typeof thing... maybe with some more boolean operatos and also number.isfloat? in that case I'm not sure what comes before what in term of order of operations: || and the &&..
thanks! I'm really new to that stuff so any help would be great :)