A Pen by YY

Thumbnail
This awesome code was written by YingYing, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright YingYing ©
  • HTML
  • CSS
  • JavaScript
    

/*Downloaded from https://www.codeseek.co/YingYing/a-pen-by-yy-odWYLo */
    


/*Downloaded from https://www.codeseek.co/YingYing/a-pen-by-yy-odWYLo */
    

function printFullAge(years) {
    var ages = [];
    var fullAges = [];
  
    for (var i = 0; i < years.length; i++) {
    ages[i] = 2018 - years[i];
    };

    for (i = 0; i < ages.length; i++) {
      if (ages[i] >= 18) {
        console.log('Person ' + (i + 1) + ' is ' + ages[i] + ' years old, and is of full age.');
        fullAges.push(true);
      } else {
          console.log('Person ' + (i + 1) + ' is ' + ages[i] + ' years old, and is NOT of full age.');
          fullAges.push(false);
             }
    }
  return fullAges;
}

var years = [2005, 2008, 1986, 1988, 1988];
var full_1 = printFullAge(years);
var full_2 = printFullAge([2012, 1915, 1999]);

Comments