-1
// Task   
// write your code here

// Do Not Edit Below   
let myStr = "zero";
console.log(myStr.addLove());
 // output needed   
    // I Love zero Web School

How i can create class with same name of variable ?

if you have any idea for solution this task could you explain it?

VLAZ
  • 22,934
  • 9
  • 44
  • 60
Abd Sh
  • 1
  • 1
    Does this answer your question? [Adding a method to Javascript String object, that will replace the string with a new one](https://stackoverflow.com/questions/49036897/adding-a-method-to-javascript-string-object-that-will-replace-the-string-with-a) - it may not be exact, but it shows you how to extend the string prototype. – evolutionxbox May 11 '22 at 15:17
  • The question doesn't ask you to create a class with the name of a variable. It asks you to add a method to strings. – T.J. Crowder May 11 '22 at 15:21
  • This is [an XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). You are not *supposed* to create a new class. You're supposed to make the code work which is the X. Your Y solution is to create a class. Yet that *cannot work* on a language level. – VLAZ May 11 '22 at 15:23
  • Thanks a lot my friends i got it ... i misunderstand what i have to do , i am added method with prototype and did it .. – Abd Sh May 11 '22 at 15:27

0 Answers0