How to implement a Developer Builder Interface? | Frontend Problem Solving | JavaScript Interview Question
@Devtools Tech

JavaScriptBeginner
429
Do you see value in our efforts?

Devtools Tech is a free platform for Frontend Engineers. It takes a lot of time, effort, and finanical resources to keep the platform running. If you see any value in our work and would like to support us then you can do using the following options.

InternationalDomestic

In this question, the candidate must implement the Developer interface that can be used to create a new developer instance and exposes different methods.

const developer = new Developer('yomesh');
  • addSkill
// Method that takes a skill (string) as input.
// Adds the provided skill to the developer
// throws an error if skill already exist
// can be chained
developer.addSkill('javascript'); 
  • addFramework
// Method that takes a framework (string) as input.
// Adds the provided framework to the developer
// throws an error if framework already exist
// can be chained
developer.addFramework('react'); 
  • getSkills
// Method that returns all skills as a comma-separated string
developer.getSkills(); // 'javascript'
  • getFrameworks
// Method that returns all frameworks as a comma-separated string
developer.getFrameworks(); // 'react'
  • hasSkill
// Method that returns a boolean indicating if a skill exists
developer.hasSkill('html'); // true / false
  • removeSkill
// Method that removes a skill
// can be chained
developer.removeSkill('html');
  • removeFramework
// Method that removes a framework
// can be chained
developer.removeFramework('react');

Methods could be chained too

const developer = new Developer('elon');

developer
.addSkill('javascript')
.addSkill('html')
.addSkill('css')
.addFramework('reactjs')
.addFramework('vuejs')
.removeSkill('css')
.removeFramework('vuejs');

developer.getSkills(); // 'javascript,html'

developer.getFrameworks(); // 'reactjs'

Loading IDE...