Lesson 2 - Learning construction - STEP 4 starting point
by nathanesa
JavaScript
// Get user input.
var celsius = prompt('Enter degrees celsius: ');
// Convert user input to an integer (number).
// Not crucial in JS for small programs, but good to know the data type.
celsius = parseInt(celsius);
// Convert celcius to fahrenheit.
var fahrenheit = (celsius * 9/5 ) + 32;
// Convert again - from integer to a string.
celsius = celsius.toString();
fahrenheit = fahrenheit.toString();
// Output concatenation.
document.write('You entered ' + celsius + ' degrees celsius, which is ' + ' degrees ' + fahrenheit + ' fahrenheit');