Javascript Bind Lab


In this lab, you'll use and be able to identify when to use bind().

Tick, tock...

Old clock

That's it. We've had to repair this old clock too many times now. Let's create a digital one instead!

  1. Create an object called digitalClock
  2. This object should have two properties:
    1. time: the current time in seconds, rounded off (Hint: take a look at Date)
    2. startTicking: a method that increases the time property with one second every second. Use .bind() or ES2015 arrow functions to correctly set the property!

So much for free speech

Fox Censor

Let's automate the censoring process for Fox TV!

  1. 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.
  2. The censor function should return the input string, with the censored word being replaced with 'BLEEP'.
  3. Create a violenceCensor function (using .bind() and the censor() function) that will censor the word 'violence'.
  4. Create a drugsCensor function (using .bind() and the censor() function) that will censor the word 'drugs'.


View Bind Lab on and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us