Code Monkey home page Code Monkey logo

temperature_converter's Introduction

Exercise: Temperature Converter

Goal: Create a program that can convert a temperature in Fahrenheit, Celsius or Kelvin to the other two units.

Setup

  • Create an index.html file.
  • Create a script.js file.
  • Make sure to link the script file in the index.html.

Specifications

Part 1

Your application should...

  • Prompt the user for a starting temperatureInFahr. This should be a numerical value that represents degrees in fahrenheit.
  • After receiving input it should log that same temperature in both Kelvin and Celsius.

Part 2

Your application should...

  • Prompt the user for a starting temperature. This should be a numerical value that represents degrees.
  • Prompt the user for a starting temperatureUnit. This will represent either Fahrenheit, Celsius, or Kelvin.
  • The application should print out the user-submitted temperature in the two remaining units.
    • So, if the user submitted 32 and fahrenheit, the program should output something like the below. Feel free to customize this however you'd like.
      32° F = 0°C = 273.15K
      

Using Conditionals, have your code accept either fahrenheit, celsius or kelvin, and output the other two temp types.

Define functions for each type of conversion to keep your code well-organized.

Part 3 (Bonus I)

Use an array to store and access the user-submitted and converted temperatures. Your array will end up looking something like this...

var temps = [ STARTING_TEMP, CONVERTED_TEMP_1, CONVERTED_TEMP_2 ];

Note on naming convention: ALL_CAPS variable names are used to mark constants, or values which do not change over the course of a program's execution.

You should have a line of code in that resembles the first line in the example below. Convert your all of your references to temperature to STARTING_TEMP (Use CMD+D or Find & Replace to make this easier).

var temperature = prompt("Enter a temperature");

// becomes

var STARTING_TEMP = prompt("Enter a temperature");

When you console.log the temperatures, make sure you do that by accessing the values stored in the array.

Part 4 (Bonus II)

Use a for or while loop to print out the conversion results for each temperature. It's OK if you need to simplify your console.log statements and remove strings.

Part 5 (Bonus III)

Using loops, create an interface that continues to ask the user for temp conversions until the user requests to stop.

temperature_converter's People

Contributors

amaseda avatar andrewsunglaekim avatar andywhitley avatar superbuggy avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.