+ 3
variable with a number and a string
how to declare a variable with a number and a string in javascript? let carEngineSize = 2000cc ; i get error message
4 Respostas
+ 7
let carEngineSize = '2000cc';
Hint:
Try to complete the JavaScript course for more information.
+ 6
Declare just a string
let carEngineSize = "2000cc";
Or do not put units
let carEngineSize= 2000;
And next at printing the data print the units:
console.log(carEngineSize+ "cc");
+ 2
Use in double quotes or you can use + sign
carEngineSize = "2000cc";
+ 2
the other option is to make it an object with two separate properties, eg
let carEngineSize = { size: 2000, units: "cc" }