Skip to content

React Unable to play audio

In my return statement of my react code I have: This creates a HTML object for the audio. I have a file called 49.mp3 in the same directory as my code. Then I have an event listener that plays that sound when a key is pressed: When I press my key, I know this function gets called but no audio

Correct result of amount of repeated values of array

I have written this code for detecting repetitive values of an array. But, it shows incorrect results, how to fix it? Output: Result Answer Firstly, you do not log the result at the right place. Only once the next character has stopped being the same have you found all duplicates (aka. in your else block). Ne…

Cannot finish a race with timer in RxJS

Code above will output 2. If I have an action that I try to repeat until condition is met but ignore it if it takes too long, then I take an approach in this answer https://stackoverflow.com/a/51644077 The problem is that race never finishes with the shortest function. The longActionObservable repeats until t…

Vuejs – cannot access $root data from component

I’m using vue.js to manage the user and I have this piece of code to initialize vue: Inside store I have: In this way, the user is correctly initialized. Now, I have also a vue component with the following: But the console.log(this.$root.store.user.state.user) inside the init() method results in null, w…