Computer Science, asked by Akaisha82, 7 months ago

Write a program in JavaScript to display the age of the user in the year 2045. Accept the current age from the user.

Please help.

Answers

Answered by siddhi1883
1

Answer:

A major goal of our recruitment survey is to identify users who are between the ages of 14-24 (target population) and those who are not (not eligible for our study). Currently we ask users for their date of birth (MM/DD/YYYY) and would like to use JS to:

Calculate age, based on the current date

Determine if the age is within our target range (14-24)

Provide a validation alert to the users AND/OR categorize users using embedded data in the categories of eligible/ineligible based on age

Please take a look at the code I have now for the DOB question:

Qualtrics.SurveyEngine.addOnReady(function()

{

var dob_entry = getTextValue();

var split_dob = dob_entry.split("/");

var month = split_dob[0];

var day = split_dob[1];

var year = split_dob[2];

var dob_asdate = new Date(year, month, day);

var today = new Date();

var mili_dif = Math.abs(today.getTime() - dob_asdate.getTime());

var age = (mili_dif / (1000 * 3600 * 24 * 365.25));

within_age_range=(14<age & age<24);

Similar questions