<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> 关系运算符小案例 </title>
<script type="text/javascript">
var num1 = window.prompt ("宇哥的IQ");
var num2 = window.prompt ("乾哥的IQ");
//强转类型
num1 = parseFloat (num1);
num2 = parseFloat (num2);
if (num1 > num2)
{
window.alert ("宇哥聪明")
}
if (num1 < num2)
{
window.alert ("乾哥聪明")
}
if (num1 === num2)
{
window.alert ("一样聪明,还是我聪明,哈哈哈!")
}
</script>
</head>
<body>
</body>
</html>
parse:解析
parseFloat:把类型强转为浮点型
网友评论