0
0
LLDsystem_design~10 mins

LLD interview expectations - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a class with a constructor in LLD.

LLD
class User {
  constructor([1]) {
    this.name = name;
  }
}
Drag options to blanks, or click blank then click option'
Aemail
Bname
Cage
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter that does not match the property name.
2fill in blank
medium

Complete the code to add a method that returns the user's name.

LLD
class User {
  constructor(name) {
    this.name = name;
  }

  getName() {
    return this.[1];
  }
}
Drag options to blanks, or click blank then click option'
Ausername
Bid
Cname
DuserName
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a property that does not exist or is misspelled.
3fill in blank
hard

Fix the error in the code to correctly implement a setter method for the user's age.

LLD
class User {
  constructor(name) {
    this.name = name;
    this.age = 0;
  }

  setAge([1]) {
    this.age = age;
  }
}
Drag options to blanks, or click blank then click option'
AageValue
Bvalue
CnewAge
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name different from the one assigned to the property.
4fill in blank
hard

Fill both blanks to create a method that returns a formatted string with the user's name and age.

LLD
class User {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  getInfo() {
    return `$[1] is $[2] years old.`;
  }
}
Drag options to blanks, or click blank then click option'
Athis.name
Bthis.age
Cname
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without this inside class methods.
5fill in blank
hard

Fill all three blanks to implement a method that updates the user's name and age only if the new values are valid.

LLD
class User {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  updateUser([1], [2]) {
    if (typeof [3] === 'string' && [2] > 0) {
      this.name = [1];
      this.age = [2];
    }
  }
}
Drag options to blanks, or click blank then click option'
AnewName
BnewAge
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent parameter names in the method and condition.