Trying string interpolation

When I run the code it does not print the proper output.

// Created by Paul A. Gureghian in April 2020 //
// This JS app converts Klevin to Celsius then to Fahrenheit //

// Declare variables 
// Declare a constant variable for Kelvin 
const kelvin = 293;

// Declare a constant variable for converting Kelvin to Celsius  
const celsius = kelvin - 273;  

// Declare a flexible variable for converting Celsius to Fahrenheit
let fahrenheit = celsius * (9/5) + 32;

// Round down Fahrenheit after conversion from Celsius  
fahrenheit = Math.floor(fahrenheit);  

// Print the temperature in Fahrenheit
console.log('The temperature is ${fahrenheit} degrees Fahrenheit.');

Hello!

That’s because you need to use back ticks instead of single quotes:

const v = "Hello World!"; // Double quotes: "
console.log('Using single quotes: ${v}'); // Single quotes: '
// Prints: Using single quotes: ${v}
console.log(`Using back ticks: ${v}`); // Back ticks: `
// Prints: Using back ticks: Hello World!

Yup. You are right. I fixed it. Thanks

1 Like