Hey guys,
I have been studying JavaScript for 3 weeks already. I'm stuck with function and these 3 tasks. If anyone could help me I would really a...
For further actions, you may consider blocking this person and/or reporting abuse
What problems or difficulties are you finding when writing these functions?
function sum(n,m){
let s = 0; //sum
for(let i = n; i<=m; i++){
s+= i;
}
return s;
}
let p = sum (5,6);
console.log(p);
You almost have it!
The cube of a number n is n3, which is
n * n * n, so you would just need to change one line:into this:
Alternatively, you could use the Math.pow function and do something like this:
Or another option would be using the exponentiation operator (**) which is equivalent to
Math.pow():How about the second one? What errors do you get in the second exercise?
wow, THANK YOU! :D :D :D
My motivation is rising uppp
This is third, but code does not work... what do you think?
function divisible(n,m,k){
result = 1;
for(i = n; i <=m; i++){
if(i%k == 0){
result = result / i;
}
}
console.log(divisble);
}
divisible(1,50,4)
EDIT: second one I have no idea how to set up
You want to know the number of numbers that are divisible by k and are between n and m, right?
Why are you doing this
result = result / i;?