Answers for "var units = "years"; var davidAge = 65; var johnAge = 40; var ageDifference = davidAge - johnAge; alert("The age difference is " + ageDifference + " " + units);"

CSS
0

var units = "years"; var davidAge = 65; var johnAge = 40; var ageDifference = davidAge - johnAge; alert("The age difference is " + ageDifference + " " + units);

The code is more readable with an appropriately named variable, 
rather than including an arithmetic expression 
inside of parentheses inside of a concatenation.
Posted by: Guest on June-16-2021

Code answers related to "var units = "years"; var davidAge = 65; var johnAge = 40; var ageDifference = davidAge - johnAge; alert("The age difference is " + ageDifference + " " + units);"

Browse Popular Code Answers by Language