【题目】
Validate if a given string is numeric.
Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true
Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
【解析】
判断一个字符串是否是数字类型,是返回true,否返回false。一看到这题我就想到了JS超级简单,JAVA的解法下次补上。。。
【代码】
var isNumber = function(s) {
if(s==" ")
return false;
var bool=Number(s);
if(bool==0)
return true;
else
return Boolean(bool);
};