Posts by Allan Juan • 418 points
16 posts
-
3
votes1
answer29
viewsA: Function running as soon as the page loads
The function addEventListener expects two parameters - the event you want to listen to, and the function that should be executed when it is fired - the first you passed correctly, the second, not.…
-
0
votes1
answer38
viewsA: How to handle dynamic payloads in Node.js?
I think the simplest is to have a common interface for the N models you have, and then you use a Factory to convert the data you received to this interface. interface Monstro { validar(): boolean; }…
-
0
votes1
answer29
viewsA: How to remove a value from a set that is inside a set dictionary?
Simply iterate through the sets, and remove the 2 of each. dicionario = dict() # Iniciando valores no dicionário dicionario['x'] = set([1, 2, 3]) dicionario['y'] = set([2, 3, 4]) dicionario['z'] =…
pythonanswered Allan Juan 418 -
2
votes1
answer27
viewsA: Error reading Localstorage array
Blusas is the type string[]. When you call localStorage.getItem('Blusas'), is returned the "stringificada" version of the sweater array that you saved in the Storage location. In other words - you…
-
0
votes3
answers75
viewsA: Store data in DB vertically or horizontally?
The first model is unsustainable. Imagine that you design the database to support up to 180 installments. That is, a table with + 180 columns. Any installments that have less than 180 installments…
-
1
votes3
answers156
viewsA: How to join 2 lists in a dictionary?
Jose, the problem is that you nestled the for. Take as an example this passage: for preco in preco_dos_itens: print(preco) It will iterate over all prices, printing one at a time. Analogously... for…
pythonanswered Allan Juan 418 -
0
votes1
answer51
viewsA: How to prove the complexity of an algorithm?
In asymptotic analysis, who dominates is the term with greater magnitude. For example, in the expression: N³ + 1000N² + 10000N + 1000000, who dominates is O N³. This pq according to N goes to…
algorithmanswered Allan Juan 418 -
0
votes1
answer128
viewsA: Relate two vectors/arrays of different types and sort them in C++
Henry, there are several ways to do this. Keep data in two different vectors, but perform mirror operations. You will have an integer vector and a string vector. However, any operation you do on one…
-
0
votes2
answers78
viewsA: Place a condition on an exported function in Node.js
The new should only be used to instantiate class objects, not to invoke functions. Furthermore, this problem is due to the fact that you are performing an asynchronous operation (a database query)…
-
0
votes3
answers430
viewsA: Assign return of findOne to a global variable Node Node.js
Another way to get the result of Promise is using await, but this command needs to be within an asynchronous function (just mark it as async). try { global.pedido = await…
-
1
votes2
answers216
viewsA: Express - req.body does not find the data sent by the customer
What is your version of Node? In newer versions, it is not necessary to use Bodyparser. The configuration I make in my applications is as follows: const express = require("express") const cors =…
-
11
votes2
answers165
viewsA: Function with two parentheses? function()()
The function connect() is returning a function. So when you do connect()(Sidebar), you’re passing Sidebar as parameter to function returned by connect and calling it. A simpler example: // Essa…
-
1
votes4
answers261
viewsA: Generate 7 random dozens using javascript and loop for? How to do?
Somewhere in your code you invoked the function gerarDezenas()? For the behavior of a function to be executed, it is necessary that you invoke it. For this we write the function name and a pair of…
-
2
votes1
answer95
viewsA: Consulting previous index in Python
I recommend you store all outputs you write in a list of strings. Then, when you need to modify the previous one, just modify it in the list. At the end you write the contents of the whole list. The…
-
1
votes2
answers223
viewsA: My print function does not work at windows command prompt
How exactly are you running the program? (I can’t leave a comment because I don’t have enough score). First you must make sure that the Python installation is ok on your machine running python…
-
0
votes1
answer28
viewsA: receiving user values other than repeated numbers
You will need to use "if" and an auxiliary vector. Simply use a Boolean vector of 20 positions, so that its i-th value indicates whether the number i has been read or not. var valores: vetor[1..20]…