Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the attached JavaScript file to implement a function constructor for Chirp. Your implementation should include all of the properties and methods described. At the
Modify the attached JavaScript file to implement a function constructor for Chirp. Your implementation should include all of the properties and methods described. At the bottom of the file are sample inputs and outputs to test your implementation.
USER HAS ALREADY BEEN IMPLEMENTED FOR YOU:
User has the following properties:
name: string
birthday: Date
User has the following method:
getDayBorn: Returns the day of the week that the user was born
example: Wednesday
function Username birthday
this.name name;
this.birthday birthday;
this.getDayBorn function
var days SundayMondayTuesday
WednesdayThursdayFridaySaturday;
return daysthisbirthday.getDay;
YOUR TASK IS TO IMPLEMENT CHIRP:
Chirp has the following properties:
author: User
message: string
date: Date
Chirp has the following methods:
postLength: Returns the length of the message, a number
example:
printPost: Uses console.log to print the message, author name, and date
example:
Hello World
By John Doe on Sat Feb :: GMTEastern Standard Time
wasBefore: Accepts a chirp and returns true if the current chirp was posted
before the provided chirp, else false
function Chirp
SAMPLE INPUT AND OUTPUT TO VALIDATE YOUR IMPLEMENTATION:
var john new UserJohn Doe new Date;
var chirpsByJohn
new ChirpjohnHello world! new Date
new ChirpjohnFirst day of spring! new Date
new ChirpjohnHappy th new Date
;
console.logchirpsByJohnpostLength;
Happy th
By John Doe on Thu Jul :: GMTEastern Daylight Time
chirpsByJohnprintPost;
true
console.logchirpsByJohnwasBeforechirpsByJohn;
false
console.logchirpsByJohnwasBeforechirpsByJohn;
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