この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
I'm using Onready function in which I'm calling a function say func();
In func() I'm using Math.ceil on a decimal value stored in a variable, but it is not working. But if I use Math.ceil in console on same variable then it is working fine.
How to use it in my function?
解決済! 解決策の投稿を見る。
You should assign the Math.ceil(..) returned value to a variable.
let xyz = 4.6;
xyz = Math.ceil(xyz);
console.log(xyz);
Hi @ShagunMalik,
What is the error that you are seeing in the console? Can you please share the log?
Thanks,
Kiran Vedantam
表示
返信
いいね!の合計
You should assign the Math.ceil(..) returned value to a variable.
let xyz = 4.6;
xyz = Math.ceil(xyz);
console.log(xyz);
表示
返信
いいね!の合計
Hi @ShagunMalik
You can use Math.ceil inside a function like below:
$(document).ready(function () {
alert(someName());
});
function someName() {
var x = 0.95;
return Math.ceil(x);
}
On page load it will give a value of 1 as alert.
And the below one gives as 5.
$(document).ready(function () {
alert(someName());
});
function someName() {
var x = 4.6;
return Math.ceil(x);
}
Thanks!
表示
返信
いいね!の合計
Instead of calling your function from onReady, try just directly adding this line of code in your HTML document:
<script>
console.log(Math.ceil(-7.004));
</script>