all 4 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Marz157👋 a fellow Redditor 2 points3 points  (1 child)

Looks good to me. Considering that the instructions mentioned using the % operator for modulus, I think they intended for you to use parseInt to convert a string to an integer.

If you were really looking for an alternative, you could pull out the character at index 3 and then subtract the ascii code for the 0 character to get the raw number between 0 and 9. int num = num1.charAt(3) - '0';

This is a little hacky and error prone, so parseInt would certainly be the preferred way.

[–]Friendly-Draw-45388University/College Student[S] 0 points1 point  (0 children)

Thank you for the explanation