Skip to content

Instantly share code, notes, and snippets.

@sferik
Last active December 16, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sferik/5448316 to your computer and use it in GitHub Desktop.
Save sferik/5448316 to your computer and use it in GitHub Desktop.

WDI Homework - April 23-24, 2013

Triangle Area

Given the following object, write an area function in JavaScript that calculates the area of triangle:

var triangle = {
  sideA: 3,
  sideB: 4,
  sideC: 5
};

Favorite Things

Create an array that contains a few of your favorite things (fruits, vegetables, colors, sports teams, whatever). Write some code in JavaScript that outputs strings like (for an array of arbitrary length):

My #1 favorite baseball team is the New York Mets.
My #2 favorite baseball team is the San Francisco Giants.
Bonus

Change the output to:

My 1st favorite baseball team is the New York Mets.
My 2nd favorite baseball team is the San Francisco Giants.

JavaScript Calculator

Create a calculator in JavaScript.

Requirements
  • Prompt the user to enter an operator and two operands.
  • Support the following operations: addition, subtraction, multiplication, and division.
  • Output may appear in the console or in an alert.
Bonus
  • Support the modulus operator.
  • Support the square root operator.
  • Support more than two operands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment