Coder Social home page Coder Social logo

hw-w01d03-functions-and-conditionals's Introduction

Homework - Week 1, Day 3: Functions and Conditionals!

Biggest Numbers

  1. Define a function maxOfTwoNumbers that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Javascript.

  2. Define a function maxOfThree that takes three numbers as arguments and returns the largest of them.

The World Translator

Write a function named helloWorld that:

  • takes 1 argument, a language code (for example "english", "arabic", "french")
  • returns "Hello, World" for the given language, for atleast 3 languages. (i.e. if the language is English, print "Hello World", if the language is Arabic write something "مرحبا بالعالم", if the language is French print Bonjour le monde)
  • Call that function for each of the supported languages and log the result to make sure it works.

The Grade Assigner

Write a function named assignGrade that:

  • takes 1 argument, a number score.
  • returns a grade for the score, either "A", "B", "C", "D", or "F"., where anything over 90 gets an A, anything over 80 gets a B, anything over 70 gets a C, anything over 60 gets a D, and anything lower than 60 gets an F.
  • Call that function for a few different scores and log the result to make sure it works.

The Pluralizer

Write a function named pluralize that:

  • takes 2 arguments, a noun and a number.
  • returns the number and pluralized form, like "5 cats" or "1 dog".
  • Call that function for a few different scores and log the result to make sure it works.

for example:

pluralize('giraffe', 5);  // returns "5 giraffes"
pluralize('door', 1); // returns "1 door"
  • Bonus: Make it handle a few collective nouns like "sheep" and "geese”.

hw-w01d03-functions-and-conditionals's People

Contributors

trevorpreston avatar nawafi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.