Posts by Andre • 5,836 points
229 posts
-
2
votes1
answer32
viewsA: Initialization of variables in Java
As in the very description you posted, just the instance variables, also called attributes, have default values. Instance variables would be variables defined at class level, not at the scope of a…
-
8
votes1
answer76
viewsA: Best practice of creating object from reduce
Best practice to use reduce is: do not use reduce where it is not appropriate to use that method. reduce is a very flexible method, you can use it to create new arrays, create objects, filter…
-
-3
votes1
answer63
viewsA: How to get only the day/month/year separately from an Input Date
The value of a single element <input> is always a string, in case of a date, it comes in the format YYYY-MM-DD (year-month-day). You can separate the string using the character - as a…
-
0
votes1
answer24
viewsA: I can’t solve ERR_HTTP_HEADERS_SENT
The call of the function next does not terminate the execution of the current function. Note that in function authenticateUser you have two calls to function next, one if the condition req.error !==…
-
1
votes1
answer49
viewsA: Passing the attribute of a list element as a method parameter
What you’re asking won’t be possible. Even if you create the code in a separate lib in pure Dart, this lib will have to be compiled in the Flutter project. The runtimes Dart script and Flutter are…
-
0
votes1
answer34
viewsA: Wait for a run function to perform the next
It seems to me that you are simulating an interval between one click and the other with these setTimeout. You can get the same result using await within an asynchronous function, and as a result you…
-
2
votes1
answer34
viewsA: Swap a character inside a string in c
As already stated in the comments, strings declared as char *string = "" cannot be modified. But why? The reason it can’t be modified is because you created a pointer referencing a string static,…
-
0
votes1
answer19
viewsA: how to use the array.find method to find an attribute of an array that is formed by the contents of the localStorage?
The localStorage does not store arrays or objects, it stores only strings. See that item localCadastro is being returned as a string, not as a array, you should be parsing this value to get the…
-
1
votes2
answers31
viewsA: Different results doing what I think is the same thing ( Mongoose js )
The operator await invokes the method then and return to you the argument that would callback. It is semantic sugar to turn functional code into imperative code. The equivalent of the first code…
-
1
votes1
answer45
viewsA: Return an array with the N first even numbers
If you invoke the function retornaNNumerosPares passing by 5 as parameter, then your loop for will only run 5 times... from 0 to 4. If you want it to run until you find 5 even numbers could make one…
javascriptanswered Andre 5,836 -
0
votes1
answer51
viewsA: How to remove the <tr> tag using Javascript
The reason the button is not working, as mentioned in the comments, is because the added button does not have a Event Listener to capture click events. One solution would be to add the Event…
-
0
votes1
answer54
viewsA: How to check if a variable is string or number?
There are some comments trying to guide the user to an answer, but I think none of them really help in this case. To verify that what was typed in input was a string or a number, do not just check…
-
-1
votes1
answer40
viewsA: Why does Mongodb (nodejs + Mongoose) not update object property of a document?
The Documents of Mongoose use setters to identify which fields of your document have changed, and optimize the update in the database to not send more than necessary. If the count is not being…
-
-1
votes1
answer40
viewsA: How could I make sure that the text is not duplicated
sc.nextInt() reads only one number, but you are asking the user to type 2. The second number the user enters will continue in the buffer, and the next time you invoke sc.nextInt(), it will read this…
-
1
votes2
answers56
viewsA: Overload of error operator
That standard you adopted for the Overload pointer got a little confused. The method has been implemented for the class Ponteiro, which means you can only use it for an instance of Ponteiro, but in…
-
1
votes1
answer56
viewsA: What are the differences between Traits (or Typeclasses) and Interfaces?
Generally speaking, when we compare a trait of Rust with a interface of Java, we noticed some differences such as In Rust, a trait can define methods, types and constants, but not mutable…
-
0
votes1
answer36
viewsA: Problem to link two structs in C
You are probably suffering at the time of de-referencing an address. See this excerpt from the code: contas[j]->Titular = &cliente[id]; With the operator -> you de-reference an address, it…
-
0
votes1
answer36
viewsA: Program stopping working in C
You declared the variable cliente as a type char. This means that it will store a single character without even being followed by a null Terminator, like strings in C. Try declaring it as an array…
-
2
votes1
answer37
viewsA: How to load a JS script when the page is not cached?
How are you trying to run this script? You are opening the developer tools and running it? If so, the script will not persist at all, it has nothing to be done. Now at the risk of trying to solve a…
-
1
votes1
answer47
viewsA: Installation bcrypt golang
It seems to me that the problem is that you are not inside the folder that has the go.mod when compiling your code. Assuming I have a project with the following structure: playground |_src |…
-
1
votes1
answer84
viewsA: Return Array Item created with asynchronous function
Two wrong ones are making a right in your code. When you do console.log(dados), there will be nothing inside that array called dados. You are only able to view the filled array because of the way…
-
0
votes2
answers80
viewsA: Message notification, similar to ALERT
In addition the forms of validation by means of Javascript already posted, I will add a direct validation suggestion by HTML The standard way to display an error message on HTML are with the…
-
3
votes1
answer31
viewsA: Jquery replaceWith deletes element when exchanging in several places
Clone the element. If you pass an element as a parameter to the method replaceWith, the method will move the element to the new DOM location. If the idea was to create a new element equal to the…
-
3
votes1
answer115
viewsA: Async Await in Javascript blocking synchronous code execution
One mistake of yours was to assume that a function declared with async will not block the other functions just by being declared as async. Another misconception was that this function will run on…
-
2
votes1
answer27
viewsA: I don’t understand a syntax that there is no comma after the declaration of a function within an array
There is no comma because this is all just a value. What is happening there is not the statement of a function, it is the call of a function. That: module.exports = { plugins: […
javascriptanswered Andre 5,836 -
2
votes1
answer160
viewsA: Put scrolling effect on my code
Just create a widget with scrolling. You can have more than one scrollable widget on your screen, if you want the entire screen to be scrollable, you can add this widget right at the root of your…
-
1
votes1
answer68
viewsA: How to make a request... Xmlhttprequest with array
Move the let ajax = new XMLHttpRequest() into your noose for. You should create an object for each iteration, the way you are doing, you are canceling the previous request by invoking the method…
-
1
votes1
answer48
views -
0
votes1
answer40
viewsA: Problems adding Spotify script with reactJS
onSpotifyWebPlaybackSDKReady is not a property of window, and as Typescript tries to keep your code consistent with the declared types, it is not letting you assign a value to a property that it…
-
1
votes1
answer46
viewsA: Manipulating Async/Await function return with JSON.parse - REACTJS
The problem is happening because your kind ret.value is a union between string and null. Even if in your test he’s a string, the declaration of this kind includes the possibility that it null also,…
-
3
votes1
answer68
viewsA: black hat book go/ variable not used in golang
That’s exactly what the mistake says. While some languages show an alert when you declare a variable but don’t use it, Go gives you a build error. This is a feature of the language that has already…
-
1
votes1
answer58
viewsA: Character counter Event.target.value in useCallback does not update to zero
Your problem arises from how React updates state after you invoke a function setStateAction. For optimization reasons, React does not update the state immediately after the function is invoked,…
-
3
votes1
answer93
viewsA: Sorting objects in Javascript
You don’t need to use two calls to the method sort, just compare the length of the words with a if, if they have the same length, return the function according to the word order, otherwise return…
-
2
votes2
answers279
viewsA: How does Undefined return work?
undefined is a value, just as null is also a value. The code needs to know what is undefined to be able to work with him. An uninitialized variable is only a region of memory that was acquired, but…
javascriptanswered Andre 5,836 -
0
votes1
answer98
viewsA: Filter in more than one column
You only need to include the conditions within the filter, returning true if the element should appear, or false if it should be filtered: const lista =…
-
-2
votes4
answers117
viewsA: How to simplify javascript "getElementByid"
There is no native shortcut, a suggestion would be to create an alias for the functions querySelector and querySelectorAll just like browser debug tools do: const $ = document.querySelector; const…
javascriptanswered Andre 5,836 -
0
votes1
answer30
viewsA: Function does not fire
Your code is not working because you are not passing a function to the event onclick. buttonClear.addEventListener('click', limparBox(celsius, fahrenheit)) buttonClear.onclick = limparBox(celsius,…
-
2
votes1
answer83
viewsA: Value input problem - Golang
This is happening because the function fmt.Scan reads the input to the first space found. Everything you give as input into the terminal, goes to a stream called stdin. What the function fmt.Scan…
-
0
votes1
answer69
viewsA: How to subtract and add dates with javascript?
As the object Moment implements the method valueOf to return time in milliseconds, you can just subtract the objects to capture the difference. Then use the method add to add the difference to your…
-
1
votes2
answers31
viewsA: Link inside a div with onclick
Your click event is triggered from the element that is clicked. Then the event "climbs" (bubbling) to the root of your document, being captured by all other ancestral elements of that clicked, and…
-
0
votes1
answer85
viewsA: Conditional If without logical comparison - I need to know what returns
There seems to be a mistake in the way you’re interpreting the workings of if. A structure if does not need to receive a comparison, it needs to receive a condition to be executed, usually true or…
-
3
votes2
answers70
viewsA: How to make calculations with instances of a class, or even with new instances?
There’s no way. Javascript does not allow operator overload, so there is no way you can implement differentiated behavior for the operator +. Related to this, the method valueOf, which is a method…
javascriptanswered Andre 5,836 -
3
votes1
answer62
viewsA: I fell in a Callbackhell?
Your code problem is not a scope problem. A callback can access variables declared at higher levels of the scope, the problem of your code is in the order in which the code is executed.…
-
1
votes2
answers91
viewsA: Problems traversing Javascript object
What you are getting from your API is not an array, it is an object that is indexing the teams by their ids. Like map is a method of objects of the type array, there is no way to invoke it on the…
-
2
votes1
answer62
viewsA: Error sending email with Sendgrid in Nodejs
Yes, that’s an import error. Modules export objects in Javascript, default is only one of the properties of this object. When you import the module, you can choose what you want to import: // isso…
-
2
votes3
answers37
viewsA: Doubt in the execution
Because the property onClick should receive a function like Handler, but you are not declaring a function, you are invoking a function and passing its return to the onClick. As the function metodo…
-
0
votes1
answer65
viewsA: Dynamic table with data coming from an input - js
I can indicate your error when trying to access the input value. I already say that there are other problems in the code, and only this correction will not make it work, but as to the question, here…
-
1
votes1
answer33
viewsA: Problem with identifying elements
There are three variables that are available for you to use in these HTML declared events, the this, the arguments, and the event. event contains the object representing the event action, in this…
javascriptanswered Andre 5,836 -
0
votes2
answers40
viewsA: How to apply a function with "foreach", using a set of pre-selected items by the Jquery style selector?
If you want to use this function setStyle as a method, you will need to use the same approach as jQuery: create a class containing all these methods. Example: class Selector extends Array {…
-
1
votes2
answers154
viewsA: Promise async/await not resolved
The problem here is that you are returning objects of the type promise for the method map. Understand that although you are declaring the callback function as async, the method map is not prepared…