实际程序完成后,document.write不显示任何内容

时间:2014-01-11 07:23:13

标签: javascript internet-explorer google-chrome rounding

function median(list)
{
list.sort(function (a, b) { return a - b; });
var list_len = list.length;

//Use  the modulus operator to determine whether the array's length is odd or even.
//Use Math.floor to truncate numbers
//Use Math.round to round numbers

if ((list_len % 2) == 1)
    return list[Math.floor(list_len / 2)];
else
    return Math.round((list[list_len / 2 - 1] + list[list_len /  2]) / 2);
} //end of function median

//Test driver
var my_list_1 = [8, 3, 9, 1, 4, 7];
var my_list_2 = [10, -2, 0, 5, 3, 1, 7];

 var med = median(my_list_1);

document.write("Median of [", my_list_1, "] is : ", med, "<br />");
med = median(my_list_2);
document.write("Median of [", my_list_2, "] is : ", med, "<br />");

document.write("Round of 6.5: ", Math.round(6.5));

我正在使用Visual Studio 2012终极版运行此程序..我得到了所有结果但最后我没有得到最后一个document.write在Internet Explorer上的结果..当我试图在谷歌浏览器上打开它时,它的工作正常..我正在上传图片,告诉你我的意思..

code written in VS2012

Output IE

Output Google chrome

0 个答案:

没有答案