为什么少于不工作? [英] Why does less than not work?

查看:71
本文介绍了为什么少于不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来非常简单,但为什么这种比较停止工作?

this seems very straightforward, but why does this comparison stop working?

if (nmax < num){
        nmax = num;
    }

我在循环中有这个,寻找最大的数字。第一个数字是105,然后是89,然后是99.然后是一个大于99的数字。第一个数字是要测试的数字,第二个数字是当前最大数字。为什么会这么坏????

I have this inside a loop, looking for the largest number. The first number is 105, then 89, then 99. then a whole munch of numbers larger than 99. The first number is the number to be tested, the second number is the 'current max number'. Why is this so broken????

101 101 VM2734:8
88 88 VM2734:8
99 99 VM2734:8
105 99 VM2734:8
756 99 VM2734:8
97 99 VM2734:8
92 99 VM2734:8
104 99 VM2734:8
98 99 VM2734:8
100 99 VM2734:8
95 99 VM2734:8
89 99 VM2734:8
96 99 VM2734:8
755 99 VM2734:8
100 99 VM2734:8
...

编辑:

这里是整个代码:

var nmax = 0;
    $(notams.rows().nodes()).each(function(key, id){
        var num = $(id).find("td:eq(0)").html();
        if (num > nmax){
            nmax = num;
        }
        console.log(num+' '+nmax);
    });


推荐答案

num有时是一个字符串。 parseInt,一切都很棒!

num was sometimes a string. parseInt and everything works great!

这篇关于为什么少于不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆