A quick and dirty way is to stringify your object and perform a regex replace:
const newApplication = JSON.parse(JSON.stringify(application).replace('[tbd]', 'Daffodil'))
It's likely this is more performant as well, but I haven't tested it. It also introduces the possibility of some nasty bugs if your new input isn't sanitized in some way, so your method is certainly better in that regard.
But this fails quite readily if any part of your object isn't stringifiable as JSON!
Also true! Just works for your example
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A quick and dirty way is to stringify your object and perform a regex replace:
const newApplication = JSON.parse(JSON.stringify(application).replace('[tbd]', 'Daffodil'))
It's likely this is more performant as well, but I haven't tested it. It also introduces the possibility of some nasty bugs if your new input isn't sanitized in some way, so your method is certainly better in that regard.
But this fails quite readily if any part of your object isn't stringifiable as JSON!
Also true! Just works for your example