Skip to content

Tag: javascript

How to find a key by value of a child element?

My JSON file (countries_numbers.json): Now I want search in this JSON file for a value. Something like that: SEARCHING: countryPrefix = “226” ¦ WHEN FOUND RETURN: “BF” ELSE RETURN “false” I hope you new what I want to do. Sry for the bad question, I’m absolute new to …

Recursion, pass function as an argument

I want to run a function certain amount of times using recursion, for example: repeat(console.log(‘Hello’), 3) should print Hello 3 times. I tried to implement such function but it prints only one word Hello. Answer A few mistakes in your code: You’re not passing the function as an argument.…

Alpine JS Table Data Binding

I’m a newbie in Alpine JS. I want to design my table with detailed rows like this: I wrote a simple HTML table like this: I tried to bind my JSON to this table. At that point, it did not work as expected. Here is what I tried: With this code, the output will look like this: User detail fields

Ball bounces along a parabolic trajectory

The question was initiated by a topic In that question, the bounces were vertical This question concerns bounces with different amounts of offset in height and length But it is difficult to realize the unevenness of movement and speed. How to implement realistic parabolic ball movement? Any idea and solution …

mock node config with jest

I introduce myself currently for the first time in jest and nodejs. I am facing the problem that I have to mock two different values from the nodejs config. the problem is that the second mockReturnValue overwrites the first one. is there any possibility to separate booth mocks from each other? Maybe with som…