Giter Site home page Giter Site logo

conditional_assignment's Introduction

Conditional Exercises

For this exercises we are going to create a file called conditionals.js. Copy the description of the exercise as a comment into the file and underneath write your JavaScript code.

Note: Remember to fork this repo, clone your copy, modify conditionals.js with your answers. Lastly git add your changes, git commit and git push

  1. Write a block of code that checks and logs whether variables are equal or not.

  2. Write a block of code that logs which of two number variables is larger.

  • Your output should look like this (in this example for the numbers x = 5 and y = 10): 'The greater number of 5 and 10 is 10'
  • If the two numbers are equal, log: 'The numbers are equal.'
  1. Create a string variable with a language code (e.g. "english", "spanish", "german"). Use an if - else if - else statement to log "Hello, World" in the given language, for at least 3 languages. It should default to logging English.

  2. Do question 3 again but this time use a switch statement.

  3. Create a variable numGrade that will contain a numeric grade (out of 100). Use an if - else if ... - else statement to log the corresponding letter grade, either "A", "B", "C", "D", or "F".

  4. Create two variables: animalName ('cat', 'dog', etc.) , and numberOfAnimals.

Use an if - else statement to log:

  • the number

  • either in single or plural form. Exp: "5 cats" or "1 dog".

Bonus: Make it handle a few collective nouns like "sheep" and "geese".

  1. Write a block of code that logs whether a given number is even or odd.

  2. Do question 7 again but use a ternary.

  3. Write a block of code that checks and logs whether a given number is positive, negative, or equal to 0.

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.