QUESTION IMAGE
Question
question: 2
you want to read input from the user to know how many apples they would like to buy. which statement should you use to read in a number from the user?
- let applestobuy = readline(\how many apples would you like? \);
- let applestobuy = console.log(\how many apples would you like? \);
- let applestobuy = readint(\how many apples would you like? \);
- let applestobuy = nextint(\how many apples would you like? \);
Brief Explanations
readLineis used to read a string input, not a number. So the first option is incorrect.console.logis used to print output, not to read input. So the second option is incorrect.readIntis a function (in some programming environments like JavaScript with appropriate libraries or in educational programming contexts) that is used to read an integer (number) input from the user. This matches the requirement of reading a number of apples.nextIntis typically used in Java'sScannerclass, but the syntax here is not correct for a JavaScript - like context (the variable declaration withletand the function call syntax) and is not the standard way in the context of this question's likely programming environment.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
C. let applesToBuy = readInt("How many apples would you like? ");