Giter Site home page Giter Site logo

js-formulas's Introduction

JavaScript Geometry Formulas

Getting Started

  • You do not need to fork or clone this repository. Simply follow the instructions.
  • Use a separate Repl.it for each problem.
  • Write JavaScript code to obtain the data prompted by each question.

Submitting your work

Each solution should be in its own repl.it project so you will need to submit 5 links to your instructors. Slack solution URLs directly to both instructors.


1. Area of a rectangle.

Write a program that calculates the area of a rectangle. Create variables to hold the length and the height and use them in the area calculation:

Rectangle area = length x width

Print the calculated area for the user.


2. Area of a triangle.

Write a program that calculates the area of a triangle. Create variables to hold the base and the height and use them in the area calculation:

Triangle area = 1/2 x base x height

Print the calculated area for the user.


3. Area of a circle.

Write a program that calculates the area of a circle. Create a variable to hold the radius and use it in the area calculation:

Circle area = Pi x radius x radius

Print the calculated area for the user. The value for PI is built into JavaScript. How do we access it?


4. Circumference of a circle.

Write a program that calculates the circumference of a circle. Create a variable to hold the radius and use it in the area calculation:

Circle circumference = Pi x radius x 2

Print the calculated circumference for the user.


5. Volume of a sphere.

Write a program that calculates the volume of a sphere. Create a variable to hold the radius and use it in the area calculation:

Sphere volume = 4/3 x Pi x radius x radius x radius

Print the calculated volume for the user.


6. Concatenating Strings

Given these three strings:

var str1 = 'Software';
var str2 = 'Development';
var str3 = 'Rules';

Write a program that will concatenate them into a single string. First, use the concatenation operator (+) and then rewrite your solution to use the String.concat() function. Print out the resulting string for the user. BONUS: Add spaces between the words in the resulting string.


7. Find First Occurrance of Letter

A pangram is a string containing all letters of the alphabet. Given the string:

var str = 'The quick brown fox jumps over the lazy dog'

Find the index of the first occurrance of the letter 'z'. Try a few other letters - since it is a pangram every letter should be present. Print out the index of the letter for the user.


8. Find a Sub-String

Given the following string:

var str = 'The quick brown fox jumps over the lazy dog'

Write a program that checks to see if it contains the following sub-strings:

var substr1 = 'ump';
var substr2 = 'brown';
var substr3 = 'Quick';

Print true or false to indicate if the sub-string is present.

Based on the results, is the comparison case-sensitive or case-insensitive?


9. Replace Word in a String

Given the following string:

var str = 'The quick brown fox jumps over the lazy dog'

We want to modify the string to change the animals' descriptions. Change 'quick' to 'small' and change 'lazy' to 'sleeping'. Print the modified string.


10. Print a Portion of a String

Given the following string:

var str = 'I am a lasagna hog';

Write a program that will print only the word lasagna.


Licensing

  1. All content is licensed under a CC-BY-NC-SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

js-formulas's People

Contributors

sixhops avatar

Watchers

James Cloos avatar  avatar Brandi Williams avatar

Forkers

floreti

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.