Funktions

Ange värdet på utrycket nedan.

1 function foo(x){return x+1}; foo(1)

2 function dubla(x){return 2*x}; dubla(dubla(3))

3 let aoo = (x,y) => (x+1)*y; aoo(3,5)

4 typeof function(){}

5 let boo = x => x*x*x; typeof boo

🪧 Vi leker med funktioner


function add(x,y) {
let result = x+y
console.log(x + "+" + y + " = " + result);
return result;
}
function mult(x,y) {
let result = x*y;
console.log(x + "*" + y + " = " + result);
return result;
}
  

🪧 Vi leker mer med funktioner


function cost(p,r,h) {
return p*r*r*cost.pi*h;
}
cost.description = "A function to calculate cost of a cylinder";
cost.pi = 3.14;
  

13 Implmentera en funktion som tar ett tal som argumnet och returnärar ett värde som är fem gånger så stort.

Faci

  1. 2
  2. 12
  3. 20
  4. function
  5. function
  6. Reflektion 💭