Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <span class="input">
  Celcius: <input id="celInput"> </input>
<br>
  Fahrenheit: <input id="fahInput"> </input>
<br>
<button class="calc" onClick="calculate()"> Calculate </button>
</span>
<span class="thermometer">
  <span class="C"></span>
  <span class="F"></span>
</span>
              
            
!

CSS

              
                html{
    background:radial-gradient(circle, #fcee92 0%,#ebcf12 50%);
}

/* Thermometer column and text */
.thermometer{
    margin:50px auto;
    width:22px;
    height:150px;
    display:block;
    font:bold 14px/152px helvetica, arial, sans-serif;
    text-indent: 36px;
    background: linear-gradient(top, #fff 0%, #fff 50%, #db3f02 50%, #db3f02 100%);
    border-radius:22px 22px 0 0;
    border:5px solid #4a1c03;
    border-bottom:none;
    position:relative;
    box-shadow:inset 0 0 0 4px #fff;
    color:#4a1c03;
}

/* Thermometer Bulb */
.thermometer:before{
    content:' ';
    width:44px;
    height:44px;
    display:block;
    position:absolute;
    top:142px;
    left:-16px;
    z-index:-1; /* Place the bulb under the column */
    background:#db3f02;
    border-radius:44px;
    border:5px solid #4a1c03;
    box-shadow:inset 0 0 0 4px #fff;
}

/* This piece here connects the column with the bulb */
.thermometer:after{
    content:' ';
    width:14px;
    height:150px;
    display:block;
    position:absolute;
    top:30px;
    left:4px;
    background:#db3f02;
}
              
            
!

JS

              
                // For this project, you will complete the code for a JavaScript program to
// convert temperatures to and from celsius and fahrenheit.


/*
  You will add lines of code within the function calculate() to make it run.
  
  you will need to look up the formula for converting fahrenheit to celsius and vice versa, and write them out as code. 
  
  you will add the code to convert celsius values to fahrenheit values.
  
  you will add the code to convert fahrenheit values to celsius values.
  
  Then, test your program by entering a value for the Celsius or Fahrenheit inputs on the page, and checking the outcomes 
  
  Do not enter values for both Celsius and Fahrenheit at the same time. 
  
*/


let cDegree = "&deg;C";
let fDegree = "&deg;F";
let inputC = document.querySelector(".C");
let inputF = document.querySelector(".F");
let celsius;
let fahrenheit;

function calculate() {
  let celInput = document.getElementById("celInput").value;
  let fahInput = document.getElementById("fahInput").value;
  if (celInput != null && fahInput == "") {
    celsius = parseInt(celInput.toString());

    
    // 1. On this line, declare a new variable named convertedFahrenheit. You will set it equal to the formula for converting celsius to fahrenheit. Use the celsius variable in your formula (it has already been declared).
    
     //2.  On this line, reassign the variable fahrenheit to equal the convertedFahrenheit variable. 

    doMathFirst();
  } else if (celInput == "" && fahInput != null) {
    fahrenheit = parseInt(fahInput.toString());
    
    // 3. On this line, declare a new variable named convertedCelsius. Set this equal to the formula to convert fahrenheit to celsius. Use the fahrenheit variable in your formula (it has already been declared).
    
    // 4. On this line, reassign the variable celsius to equal the convertedCelsius variable. 
    
    //TEST YOUR CODE!!! Input a number into the celsius input and press calculate. The values for both celsius and fahrenheit should appear on the thermometer. If you have done it correctly, 0 degrees celsius should be 32 degrees fahrenheit. 30 degrees celsius should be 86 degrees fahrenheit etc. 
    
    doMathFirst();
  } else {
    console.log("You can't put two values in at once. Remove one.");
  }
}

function doMathFirst() {
  inputC.innerHTML = celsius + cDegree;
  inputF.innerHTML = fahrenheit + fDegree;
}

              
            
!
999px

Console