Skip to content

Javascript can’t replace string

_.replace() doesn’t replacing anything in string. I tried like 5 different ways to do it but still nothing and I guess you are my last hope. My code: I want to get rid of <br /> Output: Answer You need to pass a regular expression with global flag to replace all occurrence of a pattern.

assign multiple const to the same value in Javascript

Is something like this possible? I have tried using let with no success after some research. or Answer The thing on the right has to match the destructuring thing on the left, in your case the thing on the left is looking for an array with at least four elements, so: or, make a temporary array and use its map

Change content of JSON using NodeJS

I want to edit my JSON file using NodeJS, everything work exept the last write, my JSON file get } at the end. My code : packs.json : modules.json : Result of modules.json : Answer Your disableAllModules and activateModules functions return before their respective readFile callback functions are evaluated. As…

Mocking dayjs extend

In my code that needs testing I use In my test I need to mock dayjs in order to always have the same date when comparing snapshots in jest so I did It fails with Unfortunately similar questions on here didn’t help me. How could I mock both default dayjs but also extend? Answer You could write a more tho…