Posts by Andre • 5,836 points
229 posts
-
2
votes1
answer830
viewsA: Typeerror: pokemonList.map is not a Function
View the data that this API is returning. The return has the following format: { count: number, next: string | null, previous: string | null, results: { name: string, url: string }[] } You should be…
-
5
votes4
answers1090
viewsA: How to create an array filled with values from 0 to n in javascript?
Javascript has no ready way to generate a populated array in a single row. Something I would like to be standard in Javascript would be a function range to generate an iterator. If you want to…
-
-1
votes1
answer57
viewsA: How to fix typescript types in Service Worker?
You need to declare the type of the variable this, just as you declare the types of arguments. For example: function onclickHandler(this: HTMLInputElement) { // como "this" é um input, aqui eu posso…
-
4
votes3
answers92
viewsA: Counting letters in a string
You’re just checking to see if n is on your list of tuples, when you were supposed to be checking the tuple (n, c) exists on your list Another detail is that you’re adding the tuple to your list…
python-3.xanswered Andre 5,836 -
1
votes1
answer72
viewsA: Doubt when using a Query answer in Nodejs
You already have a function that returns a promise, just use the await to unpack the result in this file, so you may not need callbacks and can simplify the code: app.get('/pesqAlimentos', async…
-
2
votes2
answers401
viewsA: does not work when you put in the onchange javascript form
This is a peculiar behavior of the browser. Within the events of each element as onclick and onchange, some variables are initialized implicitly by the browser, such as variables event, arguments,…
javascriptanswered Andre 5,836 -
1
votes1
answer34
viewsA: Problem when clicking an Object in the Javascript reflex game
Failed to assign the positioning of your element. By default, the positioning of every element is static, which means that it will simply align with the parent element by ignoring the positions set…
javascriptanswered Andre 5,836 -
0
votes1
answer370
viewsA: Problem reading csv file that has comma and comma and comma
The problem is that in CSV, the comma (,) is the delimiter for each information. In your code apparently you are using the point and comma (;) as a delimiter, but the Ncoder does not know this.…
-
6
votes1
answer81
viewsA: Function call <Function>`<Parameter>`
This notation is called tagged template. When the function is invoked with this notation, the received string is transformed into an array using placeholders ${} as delimiters, and the values within…
-
0
votes1
answer449
viewsA: Return a string in C
You won’t be able to return a string this way in C, there are some concepts you should understand to accomplish what you are trying to do. A string is just an array of bytes. The variable palavra…
-
1
votes1
answer117
viewsA: Delay keydown event when holding down button
That way it won’t even work, the event keydown is only fired once when you press the key. For convenience, your operating system has this mechanism that when you hold down some keys, it simulates…
-
9
votes3
answers189
viewsA: Global and local scope variable
You can declare again, that’s not the problem of the code you posted. let a = 2; { console.log(a); //aqui aparece 2 let a = 3; // aqui ja da erro, não aceita } You wrote aqui aparece 2, but that’s…
-
0
votes1
answer28
viewsA: Futsal (error) - Python
I don’t understand why he wants me to generate only and 1 argument being that I need 8 That’s the idea, but your code is saying that the __init__ of Goleiro takes only 1 argument, so passing 8…
-
0
votes1
answer342
viewsA: How do I print the data into a dynamically double-chained list in C?
Fernando, your first mistake is in the function insereElementoFinal. You’re allocating memory space to the node only once. You need to allocate once for each value you will store, so instead of…
-
1
votes1
answer175
viewsA: mysqli_query() expects Exactly 2 Parameters 1 Given
As the error itself says, mysqli_select_db expects two parameters, but only received 1. According to the documentation, the mysqli_select_db should receive a link, which is generated by the…
-
2
votes1
answer57
viewsA: Function does not return value with goroutines
When you use go when calling the function, the function is executed in another plane. The problem you have is that the main task does not wait for the execution of tasks in the background to finish…
-
7
votes1
answer63
viewsA: How do I create a new method for a constructor?
But in this way I learned in the books that this is not healthy for Compiler, since you are changing the prototype chain natural of javascript. Where did you read this? Change the prototype of a…
javascriptanswered Andre 5,836 -
14
votes2
answers217
viewsA: Why does this if check "if it’s ! false" instead of "if it’s true"?
There is no great mystery behind this code, it is just a practice of programming to avoid indentations. In your example it may seem trivial, but imagine larger code blocks. You may have 3 ifnested…
-
2
votes1
answer38
viewsA: Why is "this.list" Undefined?
this in Javascript is contextual. When the function add is invoked as a method of an object, as is the case of lista.add, this refers to the object, i.e., this is lista. When add is invoked within…
javascriptanswered Andre 5,836 -
1
votes1
answer290
viewsA: If function return does not recognize true, only false
The problem is that your return is within the function of callback of mysql.handle.query. The callback function is returning a value, but linkAlreadySent nay. Well, actually, linkAlreadySent is…
-
1
votes1
answer43
viewsA: Problems with Mongoosis function (nodejs)
By mistake Product.create is not a function it seems clear to me that the error is in the module ProdutoM, not in the index. In ProdutoM you are exporting your module in the following way:…
-
0
votes3
answers105
viewsA: Sum partial total lines created dynamically with jQuery
Alexandre, your code is full of PHP and AJAX that can not be simulated, unless you create a verifiable example of your problem can not offer you a good help, but I will try to clarify the code error…
-
2
votes1
answer34
viewsA: Two Clicks Javascript in one place, can one cancel the other?
You can call the method stopPropagation at the event. Imagine that when you click on some element of your page, an event is created. This click event is generated in the element you clicked on, and…
-
0
votes1
answer338
viewsA: How to put an array value in an input?
Just in this particular case, I would suggest using a "hack" with asynchronous functions to make the code more readable. How Javascript has a single thread, and there is no way to pause this thread…
-
1
votes1
answer554
viewsA: How to get the html element that is found in a given text?
As far as I know, there are queries to search for elements by id, tag, classe, atributo, but not internal HTML. You will have to make a traditional loop for. Make a getElementsByClassName or…
-
0
votes1
answer759
viewsA: onclick inside <a> tag does not work
But you want to do this AJAX via the eventListener you create in Javascript, or via the call of the function you make in the onclick? No need to create a eventListener if you are already calling a…
-
2
votes1
answer70
views -
3
votes2
answers268
viewsA: Exercise: Pair or odd championship in c
I can’t understand the logic you use to find the winner. You check whether player 1 chose pair or odd, and then you set the winner based on player 1’s fingers only, and store the amount of the…
-
5
votes1
answer176
viewsA: Pass parameters with properties c#
In your code you declare Categoria as a type string, but tries to initialize it with a double. Not only is this a mistake, but it doesn’t make sense to do it that way. If a the value of Categoria…
-
1
votes1
answer219
viewsA: Typescript error: Type 'K' cannot be used to index type’T'
Jmedeiros, this site is for Portuguese questions only. If I understand your code intuition correctly, you are trying to create a function that takes the name of a property, and returns another…
-
1
votes2
answers44
viewsA: Doubt about functions defined within constants
Because the console.log does not return a value. If you do something like var val = console.log(2 + 2); console.log(val); You will realize that val holds the value undefined. That’s because the…
javascriptanswered Andre 5,836 -
1
votes1
answer68
viewsA: I am unable to print the notes, which would be n1 and N2 of the list, I do not know if the parameter sent to the function is correct
The problem I’m seeing is that your auxiliary pointer is always the same. To create a list, with each iteration of your for, you should allocate a new space in memory and assign this space to your…
-
1
votes3
answers81
viewsA: Array reading
This error is not reproducible, so by error message I will try to deduce the error. json be coming as a string. This means that it is not possible to access the property ShippingSevicesArray of…
javascriptanswered Andre 5,836 -
2
votes1
answer61
viewsA: Testing that all asynchronous functions have been terminated
Nary, the operator await makes your code wait for the resolution of a Promise, it does not make your code synchronous. To use await, these functions need to return a promise, which I’m not sure is…
-
2
votes1
answer204
viewsA: Is it possible to define the return type of a Promise?
You just need to make use of generics to define the return of promise. In the case of a precedent that solves a number, the type of its return would be Promise<number>. As you are returning an…
-
4
votes1
answer694
viewsA: Cannot read Property 'query' of Undefined
The expression lambda, called arrow function in Javascript, it is not just a reduced way of writing a function, another feature of it is not to do the bind in the instance in which it is being…
-
3
votes1
answer11168
viewsA: Axios get giving network error
This error is happening due to a syntax error. When creating an instance of AXIOS, you should be using the property baseURL, nay baseUrl. Another improvement you could make in code is to add a block…
-
1
votes2
answers70
viewsA: Css or Javascript problem that only works in Firefox
There’s more than one problem with that code. Firstly that it should not be working even in Firefox, at least not the way you posted it, because in your HTML you declare diva and divb, but in your…
-
3
votes2
answers110
viewsA: Loop Javascript for (...)
This is happening because the function onload does not run immediately, it runs when the file is loaded, and at that point its loop has already run all iterations, so ext is with the value of the…
-
1
votes1
answer42
viewsA: Problem in bringing value to HTML
This problem is being caused because of the name variable name. name is a property that all DOM elements possess, and when you declare a variable in the global scope, it becomes a property of the…
-
1
votes1
answer478
viewsA: Adding and sorting row of matrices in python
Use the method sort. You can pass in the parameter key a callback function to generate the value that will be used to compare and organize matrix items. For this case just use the function sum to…
-
0
votes2
answers336
viewsA: Variable scope problem in foreach loop - Nodejs
The problem has been solved? Even using async in the callback of forEach, your code will only wait during the await internally in the callback. That is, the forEach awaits the answer, but its code…
-
3
votes1
answer49
viewsA: Loop "for" does not scroll through all list items
The logic isn’t wrong, but there’s a trap in that code. The return of the method getElementsByClassName is a HTMLCollection, a "live" list that is updated as you add or remove elements in the DOM.…
-
1
votes1
answer481
viewsA: How to create an event for a button in Swing/Java
You can use the method addActionListener of your JButton to pass a functional interface to the button. Functional interface is an interface that implements a single method, this method will be…
-
0
votes1
answer33
viewsA: What is the logic required to obtain the coins used in my algorithm?
It depends on the way you want the output. If you intend to use a dictionary to associate the coins with the required number, simply replace the n_moedas, the logic is basically the same: def…
python-3.xanswered Andre 5,836 -
3
votes1
answer40
views -
0
votes1
answer38
viewsA: I would like to put 2 slides equal but is having conflict in some part of Javascript, how can I put the two slides without conflicts?
The problem with your code is that you have conflicts when you make a querySelector of document, and it’s all over your code. If you want these two slides to work separately, you need a query…
-
0
votes1
answer3765
viewsA: Objects are not Valid as a React Child (found: [Object Promise]) [REACTJS]
getOmNome is a function async, this means that your return will be encapsulated within a Promise. To disembowel data from a Promise, you can use the await, but how are you doing it within the method…
-
2
votes1
answer70
viewsA: How do I align the input with the buttons - and +?
If you want to align the items vertically, I recommend using the display: flex in the parent element, as it aligns vertically within an element with display: block it’s not practical at all. Despite…
-
0
votes3
answers385
viewsA: Calculate values in sub array [PHP]
The only problem I’m seeing is that you’re not starting the variable $somar. This variable should receive the value 0 at the beginning of each loop, thus: foreach($items as $key => $res) { $somar…