Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

Normal Size Small Size show me how

Normal Size Small Size show me how

# JAVASCRIPT WEEK 2

Question | Answer |
---|---|

What is the result of the example below: <script> var sum= 0; var i; for (i = 0; i <6; i++) { sum=sum+5; } document.write("Sum= "+ sum); </script> | sum=30 |

Choose the correct: 1) While(i<30) 2) While(i<30;i++) | 1) While(i<30) |

What is the result of the example below: <script> var numbers = [0, 24, 10, 13, 11, 25]; var i=0, count=0; while(i<numbers.length){ if(numbers[i] % 2==0){ count++; } i++; } document.write("Even numbers: "+ count); </script> | Even numbers: 3 |

What does the testFunction return? <script> Function testFunction(){ var text="Hello"; return text; } </script> | Returns 'Hello' text |

In which part of the code the function named 'testFunction' is called? <script> Function testFunction(){ var text="Hello"; return text; } test=testFunction(); </script> | test=testFunction(); |

Var students=new Object(); | Create object in JavaScript |

According to the code below: student.grade=18; student.name="George"; what is the correct code in order to display the student grade? | document.write(student.grade); |

What is the result of Math.ceil(4.3); | 5 |

What is the result of Math.round(7.4); | 7 |

What is the correct code in order to calculate and display the square root of a number? | document.write(Math.sqrt(64)); |

What is the correct code in order to get a random number? | document.write(Math.random()); |

What is the result of Math.power(4,2); | 16 |

What is the result of Math.floor(8.8); | 8 |

Created by:
kcoulee