I need help with JavaScript

1 replies
Hi everyone, please consider the following code segment and tell me what is the 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>
#code #javascripthi #segment
  • Profile picture of the author Lovelogic
    The above code will produce 860
    however I suspect that's not the
    answer you were hoping to get.

    y %= 1.5; my modulo arithmetic
    is a little rusty but that line of code
    will allways return zero.


    Try y /= 1.5; that should give you
    the answer you wanted.

    {{ DiscussionBoard.errors[5812057].message }}

Trending Topics