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>
Find the value of a variable on Java Script code
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 .Â
Â