Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. [40 pts] p3-functions.js Please provide answers of code to the parts of question 2. 2. 140 pts] p3-functions.js. When you access your 111 website
2. [40 pts] p3-functions.js
Please provide answers of code to the parts of question 2.
2. 140 pts] p3-functions.js. When you access your 111 website folder in Chrome for the first time you will be prompted for the .htAccess credentials All of the following are Command-Line JavaScript exercises. You do not need to create a web page (.htm) for this requirement. User name: 111 Password: the middle 3 digits of your UO 95# Each exercise requires you to define and test a function. Put each of the function definitions in a file named p3- functions.js in your p3 folder B) Write a function named getHalfBirthday that accepts a date string (a birthday), and returns the day and month of the user's half birthday. Use function expression syntax. As you write each function, test it using the DevTools console. When it is correct, move on to the next function. getHalfBirthday("07/31/1980" ) getHalfBirthday("03/28/1986") NOTE: you do not have to include any test code in p3- functions.js. The file should contain the function definitions only-you do not have to include any console.log or alert statements. Here is an example: functions-demo.js. "9/26" getHalfBirthday("01/23/2019") "7 /24" For exercises A C, review the Date Object slides, week 4, in Canvas. +5pts eXtra Credit: format dates with leading zeros, when needed: "02/08"07/24", etc. A) Write a function named backToTheFuture that accepts a number of days and returns a date string representing a date offset by that number of days. Use function declaration syntax. C) Write a function named isLeaper that accepts a 4-digit number representing a year, and returns true if it is a leap year, and false otherwise. Use function declaration syntax. > isLeaper (2016) > true > isLeaper (2019) >false > isLeaper (1700) > false //the current date is 01/23/2019: backToTheFuture (5) >Mon Jan 28 2019 14:36:28 GMT-0800 (PT) >backToTheFuture(-5) >Fri Jan 18 2019 14:36:37 GMT-0800 (PT) > isLeaper (2000) > true Although it is easy to find solutions for this problem on the web, you must solve this problem as described in the Date Object slides from class. Solutions that do not meet this requirement will be worth zero (0) points. C) Write a function named sumOfProperDivisors that accepts an integer n>1, and returns the sum of the proper divisors of n. (A proper divisor is a positive divisor of a number, excluding the number itself. For example, 1, 2, and 3 are proper divisors of 6, but 6 itself is not.) Use a for loop, and function expression syntax. D) Write a function named sumEvens that accepts a non- negative integer n and returns the sum of the even integers 1 n, inclusive. Use a for loop that counts from 1 to n, and function expression syntax. sumofProperDivisors (6) -6 sumofProperDivisors (12) -> 16 sumofProperDivisors (8) sumOfProperDivisors (13) 1 sumEvens (10) When your functions are complete and correct (but not before), use Fugu or WinSCP to upload the .js file to your p3 folder on the server 30 sumEvens (0) 0 Remember: It's what's on the server that gets graded. Be sure to test your code on the server in Chrome. E) Write a function named sumOdds that accepts a non- negative integer n and returns the sum of the odd integers 1 n, inclusive. Use a while loop that counts from n down to 1, and function declaration syntax. 3. [30 pts] toPirate2.html, toPirate2.js, and toPirate2.css. This is an exercise in Client-side JavaScript. For CIS 111, .html files will never contain any JavaScript code-al JavaScript code will be in a .js file. > sumOdds (12) 36 sumodds (0)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started