Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I need to create a function that gets a number and return a float (not as string), how can I do it?
Function (num) {
return num.toFloat()
}
JavaScript only has a single number type. Every number is already a floating point value, following the IEEE 754 standard.
There is nothing you have to do.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 14 days ago.
Improve this question
I need to convert values of type int32 to float values
I have the value of 39900 and I need to convert to 399.00, or 7400 to convert to 74.00 or 4378 to 43.78, they are not fixed values.
You just need to divide the number by 100, this will put the last 2 digits in the fractions. You don't need to worry about integer and float weirdness from C-like languages, since in Javascript, all numbers are floats, as #pilchard has pointed out.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Im working on a simple program and im trying to put user input in it and i want to know if theres an easy way of doing that.
You can split on the comma and use map along with the unary plus operator to convert each element to a number.
str.split(",").map(a=>+a);
const str = "1,2,3,4";
const arr = str.split(",").map(a=>+a);
console.log(arr);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I need to arrange an array from highest to lowest in a function
i have used array.sort but was informed that that was not allowed for my exerccise
function minmax(array){
var ar = array.sort().join();//I cant use array.join methood
return ar
}
Please help out
One solution could be to implement any of the popular sorting algorithms, but make the comparison used prioritize larger numbers. One example is this link, the code of which only needs a > flipped to a <.
Note that if this is a homework or school excercise, copying from anywhere is plagiarism and is generally discouraged.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I came across this java script code and I don't know how I encode it. Here is a part of it:
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Can somebody tell me how to convert this into readable code?
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Its simple.
variable name _0x6ah4 ,
its an array containing 9 elements.
You can fetch the data using foreach, if you want.
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc='];
for (var line=1; line<_0x6ah4.length; line++) {
console.log(_0x6ah4[line]);
//if you need to decode , do it here
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am not sure how JavaScript manages its memory and variables.
Is it like .NET where value types are stored on the stack and the type referenced on the heap? Or is everything just saved on the heap? How does it work?