Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A B C D E The last picture is F not c You do not need to create a web page (.html) for this requirement.
A
B
C
D
E
The last picture is F not c
You do not need to create a web page (.html) for this requirement. 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.(JavaScript code using Atom)
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. / /the current date is 01/23/2019: > backToTheFuture (5) > Mon Jan 28 2019 14:36:28 GMT-0800 (PT) s backToTheFuture (-5) Fri Jan 18 2019 14:36:37 GMT-0800 (PTr) 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. > getHalfBirthday ("07/31/1980") > getHalfBirthday ("03/28/1986") 9/26" getHalfBirthday ("01/23/2019*) "7/24" e that accepts aC)Write a function named isteaper that accepts a 4-digit A) Write a function named backToTheFutur number of days and returns a date string representing a date number representing a year, and returns true if it is a leap year, and false otherwise. Use function declaration syntax. offset by that number of days. Use function declaration syntax. > isLeaper (2016) //the current date is 01/23/2019: >backToTheFuture (5) > Mon Jan 28 2019 14:36:28 GMT-0800 (PT) true > slpaper (2019) > false > isLeaper (1700) backToThePuture (-5) > Fri Jan 18 2019 14:36:37 GMT-0800 (PT) false > isLeaper (2000) true 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. > sumEvens (10) > 30 > sumEvens (0) > 0 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 > sumodds (12) > 36 > sumodds (0) 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 sumofProperDivisors ( 6 ) => 6 sumofProperDivisors (12) => 16 sumofProperDivisors (8) > 7 sumofProperDivisors (13)> 1
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