HubSpot interview question

Create the functionality "hello".addCommas(); in js

Interview Answer

Anonymous

Oct 6, 2022

String.prototype.addCommas = function() {} The function being the one mentioned in the above question, but instead of taking a string as an argument to the function you can just use this, as this is the string the function is running on when you add the function to the prototype in this manner.