Posts by leofalmeida • 751 points
25 posts
-
1
votes1
answer26
viewsA: Mocking function returning several times
I received a reply at Stackoverflow in English that helped me in the problem. Answer: the problem was that the variable timer needs to be shared between functions and not be in the local scope of…
-
1
votes1
answer26
viewsQ: Mocking function returning several times
Context: It’s the first time I’ve tried to implement a function debounce() in Javascript and I think I’m forgetting or getting something wrong, because she is making several calls in the API,…
-
2
votes1
answer48
viewsA: Problem with Javascript Card Flip
Use the querySelectorAll() to haggle all occurrences of .card and then on those occurrences with the forEach(), example: var cards = document.querySelectorAll('.card'); // Pegar todas ocorrências…
javascriptanswered leofalmeida 751 -
9
votes1
answer1265
viewsA: What is "Prop Drilling"?
What is the "Prop Drilling"? Literally, it’s the "leak of props," it’s when you pass a props, from a father to a son, the son passes to his son, and so on. This generates a "leak of props", for…
-
3
votes1
answer940
viewsA: function that decides whether it can climb on a JAVASCRIPT toy
Conditions to be true: NÃO temProblemaCardiaco E (altura >= 1,5) OU (altura >= 1,2 E vemComCompanhia), now just translate this to javascript: function podeSubir(alturaPessoa, vemComCompania,…
-
3
votes3
answers641
viewsA: What is Unobtrusive Javascript?
It is the separation of HTML from Javascript code, or in other words, its page and its content should work without Javascript, hence the emergence of Unobtrusive Javascript. Perks Easier maintenance…
-
2
votes2
answers435
viewsA: How to join repeated values of an object array, only in an object of the same array?
I managed to implement a code to solve the problem, but not nearly the most optimized and succinct (in my opinion). But at least you scroll through your array only twice, once in map and another in…
-
0
votes1
answer358
viewsA: JAVASCRIPT HELP STEP STEP
EDIT: the problem after all was why was calling the function passoApasso(), it was only necessary to write the function, the program itself called the function, so it appeared repeated the numbers.…
javascriptanswered leofalmeida 751 -
2
votes1
answer146
viewsA: Javascript - Using reduce
Answer Missed you set the initial value to 0: let array = [ { total: 231, troco: 115.5, abastecimento: 115.5 }, { total: 252, troco: 126, abastecimento: 126 }, { total: 374, troco: 224.4,…
javascriptanswered leofalmeida 751 -
2
votes4
answers1090
viewsA: How to create an array filled with values from 0 to n in javascript?
You can do this using only one line, using the methods keys() and from() of ES6, as follows: let array = Array.from(Array(10).keys()); console.log(array); Or using thespread operator, gets smaller…
-
4
votes2
answers2782
viewsA: How to catch the children of an element with Javascript?
If you want an element, just do as you did to catch the father: var pai = document.getElementById("minha-div"); var filho1 = document.getElementById("filho-1") // Aqui console.log(filho1);…
-
8
votes2
answers164
viewsA: What would this . f be in Javascript?
1°: what would this f? In this example: let user = { name: "John" }; function sayHi() { console.log(`Hello ${this.name}`); } user.f = sayHi; // dúvida user.f(); // retorna Hello John In doing user.f…
-
3
votes1
answer264
viewsA: How to use setState in if Else
Not use setState inside render(), this can cause infinite loops, because the method render is called when the state is updated, so when you put the setState within the render, it will update the…
-
5
votes2
answers216
viewsA: What are the correct tools to debug Javascript code for viewing in the Browser?
It’s okay to use the console.log() for debugging, but it’s very limited. I’ve always used it (and I use it when I’m lazy), but for some things it’s easier to use the tab Sources from your browser’s…
-
3
votes1
answer889
viewsA: convert whole to java string
Use String.valueOf() String matriculaString = String.valueOf(txtmat.getMatricula()) txtmatricula.setText(matriculaString); Perks Also for the types: Double, Float or Long; It has the purpose of…
-
0
votes1
answer81
viewsA: How to use bootstrap datepicker to disable some dates
Just set the endDate for +0d: <script> $(function(){ $('.datepicker').datepicker({ format: 'mm-dd-yyyy', endDate: '+0d', autoclose: true }); }); </script> Link to thread in English:…
-
-1
votes1
answer1401
viewsA: URI Online Judge 1021 - Wrong Answer 100% (Javascript)
Probably by the statement, he just wants integer values. The way you’re doing, for example: you get the valor = 50, and when divided by all notes, you divide by 100 too, which gives an output of 0.5…
-
1
votes2
answers284
viewsA: Problems while rescuing data from a json file
If you’re using Chrome, this is a known bug from Chrome itself: Link:…
-
3
votes3
answers993
viewsA: Remove "disabled" with Javascript
Just set the attribute disabled for false. const t = document.querySelector("#text1") t.addEventListener('keyup', function(e){ var key = e.which || e.keyCode; if (key == 13) { //quando a tecla enter…
-
0
votes1
answer303
viewsA: Sum of two floats with 2 decimal places resulting in 4 decimal places in JAVA
That’s right, that’s because of conversions, and it happens not only in Java, but in many other languages, you’re not doing it wrong. If you want to format, make calculations or in your case, so it…
-
0
votes2
answers75
viewsA: Error in Arduin (pointer to struct)
Try to remove the typedef struct /*Estrutura que abstrai a seringa*/ struct { int pot[7]; float nivel[7] = {0, 0.5, 1, 1.5, 2, 2.5, 3}; } seri; /*Definição do tipo de dado abstrato Seringa*/ seri…
-
0
votes1
answer382
viewsA: native onChange on React
Just use the onBlur instead of onChange. Example: onChange(event) { console.log(event); // só irá emitir esse evento, ao sair do campo } ... return ( <Input value={value} onBlur={onChange}…
-
0
votes3
answers308
viewsA: Doubt when exporting Promise
You don’t need to use the await in the return, response already has the result of the call, that is, the Promise has been solved. Edit: It is necessary to use async/await or then() in function call…
-
0
votes1
answer78
viewsA: Error accessing property with map function
arrayMenu is receiving all data from your API, including objects menu and submenu, when making the map you assign to the jsonMenu the menuItem.menu, this for all items on your list. Only when you…
-
0
votes2
answers96
viewsA: [[Promissevalue]] React
In addition to what Matheus said, it is necessary to return some function value isAdmin(). For example, if your api returns true or false on request, just use async/await, store the value in a…