Is there a method or something alike to check wether a number is a float?
I'm receiving string arrays from server, and I need to perform some operations on the elements that compose them depending their type. I tried this to figure out the type of the elements:
let a = [4, 2.3, "SO2", 4, "O2", 3.4, 4.5, "CO2", 5.6, 3.4, 2];
itExists = true;
a.forEach((e,i,a)=>{
if(true){
if(typeof e == 'number'){
if ( e % 1 != 0) {
console.log(e + " :float")
}else{
console.log(e + " :number")
}
}else{
console.log(e + " :letter")
}
}else{
console.log("Does not exist")
}
});
However, this doesn't work, as they are strings. Any idea?