Js Functions Lab

Objectives

  1. Write a function that returns a value
  2. Write a function that takes in a parameter
  3. Write a function that takes in multiple parameters

Instructions

You'll be writing your solution in index.js.

In this lab, we're going to develop our communication skills in JavaScript. We're feeling festive, so we're going to be wrapping up common holiday greetings as functions so that we don't have to repeat ourselves. The beauty of functions is that we could reuse these functions for the text of greeting cards, for spoken greetings, for song lyrics, etc.

  1. Write a function named happyHolidays. This function should not accept any parameters and should return the string "Happy holidays!".

  2. Write a function named happyHolidaysTo. This function should accept a parameter of the name of the person you want to wish happy holidays, and return the string `Happy holidays, ${name}!`

  3. Write a function named happyHolidayTo. This function should accept two parameters, the holiday you want to wish them well for, and the name of the person you're wishing well. This function should return the string `Happy ${holiday}, ${name}!`

  4. Write a function named holidayCountdown. This function should accept two parameters, the holiday name and number of days till that holiday. The function should return the string `It's ${days} days until ${holiday}!`

View Functions Lab on Learn.co 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