lundi 27 juin 2016

I'm just learning how to code in school and I'm struggling like crazy

In this assignment, you will need to work through each of the steps and figure out what the value of the variable equals each step of the way. Once you have worked out what the value is at each step, send an email to your instructor letting us know what you think the answers are.

variable created: var x = 3;

step 1, what does x after the changes in the code below? x = x + x

step 2, what does x after the changes in the code below? for(var i = 0; i < 4; i++){ x = x + 1 }

step 3, what does x after the changes in the code below? if(x > 10){ x = 2; } else { x = 3; }

step 4, what does x after the changes in the code below? function doubleIt(value){ return value*2; }

doubleIt(x);
x = doubleIt(x);

step 5, what does x after the changes in the code below? var numberArray = [1,2,3];

for(i = 0; i < numberArray.length; i++){
    x = x + numberArray[i];
}

Aucun commentaire:

Enregistrer un commentaire