In this lab, you'll use and be able to identify when to use bind()
.
That's it. We've had to repair this old clock too many times now. Let's create a digital one instead!
- Create an object called
digitalClock
- This object should have two properties:
time
: the current time in seconds, rounded off (Hint: take a look atDate
)startTicking
: a method that increases thetime
property with one second every second. Use.bind()
or ES2015 arrow functions to correctly set the property!
Let's automate the censoring process for Fox TV!
- Create a function called
censor
. This function takes two arguments: the word being censored, and the string that should be sanitized. Don't worry about case matching for this exercise. - The
censor
function should return the input string, with the censored word being replaced with'BLEEP'
. - Create a
violenceCensor
function (using.bind()
and thecensor()
function) that will censor the word'violence'
. - Create a
drugsCensor
function (using.bind()
and thecensor()
function) that will censor the word'drugs'
.
View Bind Lab on Learn.co and start learning to code for free.