+ 2
Why am I having a hard time learning about functions that use parameters??
I'm trying to beat a simple challenge on CodeWars but functions that have parameters are making me bash my face into my keyboard. I understand that a parameter is a variable included into a parameter but i have no clue as to how to define the var and get it to do what I need it to do. It's a level 8 kyu....
8 Respuestas
+ 5
Well it's something. Here you go:
function coolZone(num) {
return num * 3;
}
var threeTimesTen = coolZone(10);
To figure out what the last line does, you can do "substitution": Everywhere you see a `num` in the function body, replace it with 10 in your mind. What comes after the `return` is what will be stored in `threeTimesTen`.
+ 4
Try finish the python course you are already learning...trust me, everything will be fine
+ 2
hmm, can you write a function that takes a number and returns that number times 3?
+ 1
Schindlabua thanks for helping me. I'm going to try practicing this. I think it can't get anymore simple than what you showed me.
+ 1
ex...
function functionName(par1,par2) {
this.par1 = par1;
this.par2 = par2;
return par1*par2;
}
ex2.
function(x,y) {
this.x =x;
this.y =y;
let h= document.getElementById("random");
let i, j, k;
return x+y;
}
yea parameter are like local variables...they can only be used inside the function itself or any inner function that.
you can pass arguments into your paraments. and get some results.
some simple examples to help out
0
function coolZone(code){
code = 5;
coolZone(1 * 3);
(coolZone) * 5);
}
Please forgive me for the above bad attempt at coding...
0
I was trying to learn Python on here but it seemed like it was counterproductive since i don't have a decent grasp on JS yet.
0
^^^ that code wouldnt work in js