我该如何解决这个问题? Javascript
How do I solve this ? Javascript
问题是:
Declare a variable called x
and assign it a value that equals the remainder of 20 divided by 3. Next, divide and assign 1 to that variable and display the result in an alert box. The result should be 2.
这是我的代码:
var x = 20 / 3;
alert(x / 1);
我是 Javascript 的新手。我想出 6.66。答案应该是2。我做错了什么?
那么 JS
中还有 %
剩余。 /
是除号。
var x = 20 % 3; console.log(x / 1);
你需要这个:
the remainder of 20 divided by 3
你分裂。 JavaScript 中的余数(或取模)运算符是百分比符号 (%
).
因此您的代码应该如下所示:
var x = 20 % 3;
alert(x / 1);
进一步阅读:
问题是:
Declare a variable called
x
and assign it a value that equals the remainder of 20 divided by 3. Next, divide and assign 1 to that variable and display the result in an alert box. The result should be 2.
这是我的代码:
var x = 20 / 3;
alert(x / 1);
我是 Javascript 的新手。我想出 6.66。答案应该是2。我做错了什么?
那么 JS
中还有 %
剩余。 /
是除号。
var x = 20 % 3; console.log(x / 1);
你需要这个:
the remainder of 20 divided by 3
你分裂。 JavaScript 中的余数(或取模)运算符是百分比符号 (%
).
因此您的代码应该如下所示:
var x = 20 % 3;
alert(x / 1);
进一步阅读: