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
The following program is meant to print the total value of a trade, but currently results in an error:
function main() { let price = 8; let count = 30; printValue(count); } function printValue(num) { let value = unitPrice * num; console.log(value); }
Which of the below options should be implemented in order to fix the program?
Include unitPrice as a parameter on line 8 after num and price as an argument on line 5 after count.
unitPrice
num
price
count
Change the name of unitPrice to be “price” on line 9 so that it matches the name on line 2.
Change console.log(value) on line 10 to be return value;.
console.log(value)
return value;
Both options A and B need to be implemented for this program to run properly.