Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
What is the output of the following code?
function main() { let feet = 2; convertLength("centimeter"); let conversion = convertLength("inch"); let convertedLength = feet * conversion; console.log("Converted length = " + convertedLength); } function convertLength(unit) { let length = 0; if (unit == "inch") { length = 12; } else if (unit == "centimeter") { length = 30; } return length; } main();
Converted length = 2
Converted length = 12
Converted length = 24
Converted length = 30
Converted length = 60