Reputation: 11
below code to get equivalent Fahrenheit of 12 degree Celsius throws an error saying missing ;
var celsius = 12;
var fahrenheit = celsius x 1.8 + 32;
console.log(fahrenheit);
Upvotes: 0
Views: 332
Reputation: 5454
x
isn't a valid operator; though I can see how it could be overlooked.
fixed:
var celsius = 12;
var fahrenheit = celsius * 1.8 + 32; // x not an operator
console.log(fahrenheit);
as a function:
const fahrenheitFromCelsius = (deg) => deg * 1/8 + 32;
Upvotes: 0
Reputation: 3692
Multiplication is done with *
in JavaScript.
var celsius = 12;
var fahrenheit = celsius * 1.8 + 32;
console.log(fahrenheit)
Upvotes: 3