0
I’m starting in javascript and came across a question. I need the user to enter their date of birth, which I will store day, month and year in several different. What I need is to separate the values of these variables and then make a sum with them.
For example, the user inserts that the year of birth is 1994, so I need my program to do 1 + 9 + 9 + 4 = 23, which will be stored in the year variable.
Thank you!
Hi Lucas, what have you tried? Could you update your question with relevant code?
– Anthony Accioly
You already have something implemented so that we can work with it ? The field that the user will put will be text, date ? Please put more information to make the scenario a little clearer, because depending on the answers the solution can change
– Felippe Tadeu
I’m on the phone right now and I can’t access what I was trying to post right now. But the field the user places is stored as a string, with a validation as to whether the format is correct: day and month with two digits and year with four.
– Lucas Maraal
What is the goal of adding up each digit of the year ? How will you get the year back after this calculation ?
– Isac
Oi Issac, in each stage of the program he reduces (sum of digits) the highest value, from right to left, between day, month and year, until the sum of these is less than or equal to 22 and finally he associates this number with a "luck".
– Lucas Maraal