I’m a beginner with TypeScript (Day 1), but have worked on above average JavaScript projects. I’m looking for advice about some “best practices” and standards when it comes to declaring or assigning types in code. At the moment, I find myself doing it for literally everything which is …
Tag: javascript
HTML Javascript redirecting user with if statement does not work
I want to use user input to decide whether or not the user is redirected to another page. In this case, the user inputs a username and password. If the username and password is correct, then the user is redirected. For this, I use simple javascript and html: However, when I fill in the correct username and pa…
React.js: How to change icon when item in the list is clicked?
I’m trying to implement a logic, where based on clicked item, arrow down icon changes to arrow-up and if user clicks 2nd time to the same row should again change. I tried to trigger it based on the index of clicked item, but doesn’t work properly. Also tried to change the icons based on boolean st…
readPixels from WebGL2RenderContext returns only black pixels
So there is a game online that uses WebGL2 and WebAssembly. My goal is to interact with the game by script. It uses pointers internally which makes it hard to read data from the game data. That’s why I decided to go over the UI using the WebGL context. I’m very new to WebGL, graphics and rendering…
Babel 7.18 doesn’t transpile components outside the project root directory
I have a component sharedlib outside the babel root directory of project1. I used to use webpack to package this project without problems, but when I configured babel, I got the following error: The demo project to reproduce the problem is on github https://github.com/xybei/test_babel My project directory is …
How to filter one array with another array values and return a key value of the first array
I have 2 arrays with current week dates and investments with value and date. I want to return an array with the values that have corresponding dates between the 2 arrays. My non-working solution is: When what I need is: [0.77, 1.50, 0.80, 1.00, 0.77, 0.79] Probably the filter inside the map is not the best op…
Node JS multliple promises chaining
I have node JS api server and I’m having issues with correct chaining of the Promises: What I get in console is : 1 [Object] – all good Emppty Array Empty Array get one doc {object} – all good 1.5 {object} – all good How would I make sure when I loop over result of 1st promise my code …
Hidden password only works in one input box
I have this JS code that shows 2 input boxes that asks for a password: 1) Password 2) Confirm Password. However, the clickShowPassword() is only connected to Password. [Output] [1]: https://i.stack.imgur.com/IZoa3.png Here’s my whole js file that is connected to an react application. Answer In your seco…
how to store the value of a key for a object and pass it to the function which is a value of another key in the same object
In the above object inside dateFilter for value i am using a calculateAverage function to get the value i need to pass the same value as parameter for calculatePercentage which is a value for percentage key in the same object how to store the calculateAverage at dateFilter and pass it to calculatePercentage s…
Javascript returning SUM 0
Sorry for this basic JS question. I have this code: my value is always 0. I know it’s because let is not changing, but I don’t know why. Could you help me, please? Answer parseInt(‘0.3’) is 0. So one of your values is 0, so the result will always be 0. Try using parseFloat instead.