Company: Decendro_19_jan_MCQ
Difficulty: medium
Janitor and Cashier classes have a print function that is similar. How can we refactor this code to reduce repetition? class Janitor { print(){ console.log("Employee Name: " + self.name) } } class Cashier { print(){ console.log("Employee Name: " + self.name) } } Replace 'self.name' with a getter method to encapsulate the member variable. Replace the 'print' method with a 'toString' method. Use this new method to display data to the console. Move the print methods from both the classes to a superclass. Create a 'print' function outside both classes and call that function in the print method of both classes. Which of the following is a valid way to clean the code? const stringA = "test" const stringB = "this" let hashStringA = 0 for(let i = stringA.length; i >= 0; i--){ const charCode = stringA.charCodeAt(i) hashStringA = 32 hashStringA = charCode } let hashStringB = 0 for(let i = stringB.length; i >= 0; i--){ const charCode = stringB.charCodeAt(i) hashStringB = 32 hashStringB = ch