Find the value of a variable on Java Script code

Asked By 0 points N/A Posted on -
qa-featured

Hi everyone, please consider the following code segment and tell me what is the values z after executing the code segment

<script language="JavaScript" type="text/JavaScript">
<!–
x = 800;
y = 45;
x += 60;
y %= 1.5;
z = x + y;
–>
</script>

SHARE
Answered By 40 points N/A #94811

Find the value of a variable on Java Script code

qa-featured

Hi Mary , 

This is a simple code i guess , I think i can find an answer for this I  guess.

1. First step is that x is initialized and now the variable x has 800 as value . 

2. y is initialized and it has 45 as value.

3. x+=60 is short of x = x + 60; so x has now 800 + 60 that is 860.

4. y%=1.5 is a short code of y=y%1.5 that is 0.675 

5. z= x + y so z = 650 + 0.675 

So final value z is having 650.675

Hope that solves your problem . 

 

Related Questions