ChatGPT Overcomplicates padStart
No, there is no built-in JavaScript function to fill a string with a character from the left until a certain length. However, you can create your own function which may look something like this: function leftpad(str, len, char) { if (str.length >= len) return str; var missing = len - str.length; for (var i = 0; i < missing; ++i) { str = char + str; } return str; } padstart? Yes, the method you are looking for is String.prototype.padStart(). It takes in two arguments: Target length - Number of characters in the resulting string. Character to pad with (optional).
A ChatGPT conversation shows the assistant writing a long custom JavaScript left-padding function, even though the user only asks “padstart?”. ChatGPT then correctly identifies the built-in String.prototype.padStart() method, creating a joke about overcomplicating a simple programming question. EN: A ChatGPT conversation shows the assistant writing a long custom JavaScript left-padding function, even though the user only asks “padstart?”. ChatGPT then correctly identifies the built-in String.prototype.padStart() method, creating a joke about overcomplicating a simple programming question.
- @gentoomemes / 2431 2023-02-14
- Type
- image
- Size
- 613×800 · 57.0 KiB
- Mood
- саркастичный, абсурдный
- Language
- en
- Added