COMSSE319 Homework 3-Event Handling Solved

35.00 $ 17.50 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


Rate this product

This assignment is focused on node.js and Event Handling. You need to implement the solution using javascript and nodejs. Task 1: Event Handling

Write Javascript and HTML code (named snake.html and snake.js) to implement the functionality shown in        ‘Task1Output.mp4‘      included           in            the        zip        file.      Some    example            code     is          given    in task1/ExampleCodesGeneral as well.


  1. The line you create can go over any upcoming paths.
  2. The line will bend left when the left button is clicked.
  3. The line will bend right when the right button is clicked. 
  4. The line should stop in following conditions: [8 poin]
    1. The snake touches the edges of the rectangle 
    2. The snake’s head touches its body [2 points].
    3. User clicks on the “stop” button [4 points].
  • When the user clicks on the “stop” button, the button text should change to “start”, which allows the snake to continue move if there are no boundaries as those given in 4a and 4b.


1.     Use HTML5 Canvas (see

  1. Make sure to use a timer (see example below and in task1/ExampleTimer/timer.html) to update the canvas (so that the snake keeps moving). A Timer has two main functionalities that can be used in the project.
  1. The setInterval(function, delay) schedules the “code” after every “delay” microseconds.
  2. The clearInterval removes the timer

Here is an example of timer code. This will countdown from 100 until you press stop!

Task 2: (25 points)


Learn to use node.js programming.

NOTE1: Play with the given “example.js” in task2 sub-folder. Open using a text editor of your choice and modify to learn how the different instructions work.


Note: It will be a console based application.

Your assignment is to create a program in node.js named “hw3.js” that can do the following operations. You can start with the given warm-up example “example.js” and follow lab activity 3. You need to install ‘readline-sync’ like here.

  1. Take four integer numbers as input from the console using ‘readline-sync’ like given example code. So, the user should be given a prompt for entering all 4 numbers one by one then need to press enter for getting the output. (5 points)
  2. Calculate the factorial of the first number. In the console, the factorial of that first given number should be shown as an output. (5 points)
  3. Calculate the sum of all the digits of the second number. For example, if we have the number

1234, the program will calculate 1+2+3+4 which is equal to 10. (5 points)

  1. For the third number given as an input, show the reversed number as an output. For instance, if we give 12345 as input, it will show 54321 as output (5 points)
  2. For the fourth number given as an input, check whether that number is a Palindrome or not and show the output as True in case it is a palindrome and False if it is not a palindrome. For example, if we give “12345” as an input it will return false but if we give 12321 as input, it will return true. (5 points)

Sample Input and Output: