“Calculer l'âge à partir de la date de naissance Javascript” Réponses codées

JavaScript obtient l'âge

function getAge(dateString) 
{
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) 
    {
        age--;
    }
    return age;
}
DigitalBorder

JavaScript élabore l'âge de la date de naissance

// To calculate age:
var year_born = prompt("Please enter your date of birth:", "Type here");
var d = new Date();
var n = d.getFullYear();
function getAge(birthYear){
	var currentDate = new Date();
    var currentYear = currentDate.getFullYear();
    age = currentYear - birthYear;
    return age;
}
calculatedAge = getAge(year_born);
alert("Hello, " + "you are " + calculatedAge + " years old!");
Hello There

Calculer l'âge à partir de la date de naissance Javascript

let car = function  (name,model,color){
    this.name = name;
    this.model = model;
    this.color = color;
  //  console.log(model);
    
}
let car1 = new car ("beast", "2022","darkBlue");
let car2 = new car ("sienta", "2001","darkBlue");
let car3 = new car ("wish", "2011","darkBlue");
let car4 = new car ("bmw", "2010","darkBlue");

 console.log(car1);
Nicholas Edgar Kiwanuka

Calculer l'âge à partir de la date de naissance Javascript

let car = function  (name,model,color){
    this.name = name;
    this.model = model;
    this.color = color;
  //  console.log(model);
    
}
let car1 = new car ("beast", "2022","darkBlue");
let car2 = new car ("sienta", "2001","darkBlue");
let car3 = new car ("wish", "2011","darkBlue");
let car4 = new car ("bmw", "2010","darkBlue");

 console.log(car1);
Nicholas Edgar Kiwanuka

Réponses similaires à “Calculer l'âge à partir de la date de naissance Javascript”

Questions similaires à “Calculer l'âge à partir de la date de naissance Javascript”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code