Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I want to calculate 17% from 835 and after reduce from n the resulted number.
But the resulted number is 693.5 and I want to show downwards to the nearest integer 693.
The Math.floor should do that but I don't understand why the resulted number shown is 694.
Thank you.
function compute_active_users(n, b) {
// Write your code here
var s =b/100*n;
var b =Math.floor(s);
console.log(n-b);
}
compute_active_users(835,17);
Okey you should do
function compute_active_users(n, b) {
// Write your code here
var s = b /100 *n;
var b = Math.floor(n - s);
console.log(b);
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
Try printing stars in the following format for n rows.
*
**
for n times
let n = 4;
for (let i = 0; n >= i; i++) {
console.log('*'.repeat(i))
}
Something like this should help you. Please ensure to read contribution guidelines and maybe show what you've tried. This is a simple implementation which should help you.
Good luck!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
i am trying to perform addition in javascript. below is my code :
function myfunc(size){
var m = parseInt(size)+5;
alert(m );
When i use 'alert',it works perfectly.. but i want to use sweet alert and it is not display anything via sweet alert. when i do:
function myfunc(size){
sweetAlert(size );
it does display the size using the code above. the problem is, it doesn't work when i try to perform the addition. why is it so?
try something like this
import swal from "sweetalert";
function myfunc(size) {
var m = parseInt(size) + 5;
swal(String(m));
}
myfunc("6");
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I want to figure out what return -1 and return 1 did in following code
https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_sort_object2
If car a is in lower alphabetical order than car b then -1 is returned, if it is higher then 1 is returned, and if they are the same then 0 is returned.
Given a sorting criterion, let us consider lexicographical ordering, there can only be three conditions that exist between two letters/number, a and b.
The condition are as follows:
a = b/both are equal, return 0
a < b or a occurs before b, return -1
a > b or a occurs after b, return 1
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
function first(array){
return first(0);
var first = ["gold","brown","green"21,1998];
console.log(first[0]);
trying to create a function that will return the first object of a given array, and am getting an error self[e.data.invoke.func].apply is not a function
not sure what I'm missing?
I tried this and it worked
function firstObject(array){
return array[0];
}
var first = ["Weresquirrel", "Werebear", "Werepanda", "Weremonkey"];
console.log(firstObject(first));
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
if(MathRScore > 29.9 && MathRScore < 34.9 ) MathScore = 10*Math.round((MathRScore*45/5+(535*35-580*30)/5)/10);
I've inherited this tiny line of exception code for a scoring algorithm I'm maintaining. I'm not sure what it does exactly. Can someone walk me through it?
If your MathRScore is in the interval (29.9, 34.9) then set the MathScore to (in simplified form)
MathScore = 10*Math.round((MathRScore*9+265)/10)
By dividing by 10, then using Math.round and then multiplying by 10 you will round to the nearest ten.
For example
10*Math.round(1111/10) = 10*Math.round(111.1) = 10*111 = 1110
if the value of MathRScore is between 30 and 34.8 , it will make the variable MathScore hold the value of 10 times the rounded value of all that stuff in the parenthesis.
If MathRScore is between 29.9 and 34.9, exclusive, then set MathScore to the value:
(MathRScore * 9) + 265
rounded to the nearest 10.
Beyond that, what this means can only be revealed by understanding how these scores work, and we can't tell you that.