Welcome to Westonci.ca, the ultimate question and answer platform. Get expert answers to your questions quickly and accurately. Discover detailed solutions to your questions from a wide network of experts on our comprehensive Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.
Sagot :
Answer:
For the value of 7 of num, there are actually two if statements that are true and their contained code is executed.
So your line numInfo = "lucky sevens!"; is executed for sure, but then numInfo gets overwritten with by numInfo = "a single digit.";
To fix it, you have to decide how you want the program to behave, since technically, both numInfo's are equally correct.
- if you want to execute at most one if condition, chain them together like if (...) { ... } else if(...) { ... } etc.
- if you want to return multiple numInfo's, turn it into a collection where you add strings
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.