Sobes.tech
Intern — Middle

User object constructor with name and age parameters

livecode

Task condition

Implement a constructor function that takes two arguments — name and age. The function should create an object with properties corresponding to the passed values.

function User(name, age) {
    this.name = name;
    this.age = age;
}

After calling new User('Alice', 30), we get an object { name: 'Alice', age: 30 }.