79739142

Date: 2025-08-18 19:01:47
Score: 0.5
Natty:
Report link

Why not just the following?

str.replace(str.charAt(0), "h")
String.prototype.replaceAt = function(index, replacement) {
  return this.replace(this.charAt(index), replacement)
}

Or, in a slightly less potentially disastrous way of monkey patching…

Object.defineProperty(String.prototype, "replaceAt", {
  value: function(index, replacement) {
    return this.replace(this.charAt(index), replacement)
  }
})
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Why not
Posted by: Daniel Bayley