Posts by Leo Letto • 3,303 points
170 posts
-
3
votes2
answers87
viewsA: Regex to catch single word
When using the /g as a flag, you are specifying to search across the "global" string and replace, you could simply not put g as a flag, this forces regex to return only the first found result. let…
-
1
votes1
answer1903
viewsA: Cannot destructure Property `name` of 'Undefined' or 'null'
Do not use classes if you do not need them, they are complex objects and should not be used uselessly, everything you wrote in for your App could be reduced by: const app = express();…
-
2
votes5
answers2360
viewsA: Typescript error Property 'user' does not exist on type 'Request<Paramsdictionary, any, any, Parsedqs>'
Hello, as it was not mentioned I suggest that you are using a newer version of Typescript, if this is the case the problem can be solved as follows: - raiz - @types - express - index.d.ts Above is…
-
1
votes2
answers44
viewsA: Problem with inheritance in css
By adding a comma to the list of tags you are listing which are the targets for that style, in your case: .button_profile button,label, a you are setting a style for all button who are children of…
-
1
votes4
answers117
viewsA: How to simplify javascript "getElementByid"
You can define an array with the ids of the elements that should be affected, and make a cycle that toggle for each of them, example: // Supondo que todos os elementos tenham "input-" como prefixo…
javascriptanswered Leo Letto 3,303 -
2
votes1
answer63
viewsA: Difficulty with FETCH API authorization
You are setting the headers incorrectly, the values are defined by chave: valor, then the right thing would be: fetch('https://api.api-futebol.com.br/v1/',{ "method":"GET", "headers": { // Chave :…
-
1
votes1
answer42
viewsA: Javascript Programação
You can use the offsetWidth for this, example: function changeSize(){ const element = document.getElementById('myDiv'); if(element.offsetWidth === 0){ element.style.width = '200px'; } else {…
javascriptanswered Leo Letto 3,303 -
2
votes3
answers73
viewsA: How could I decrease my code?
Tip don’t mix code with Markup (HTML) and much less style(css), let each one do their own the way they have to do. Use Function where you can avoid repeating pieces of code that do the same thing,…
javascriptanswered Leo Letto 3,303 -
0
votes1
answer122
viewsA: Function returning Undefined
Take some of your time to read to read about How not to ask questions. What you need is to return one Promise of the method getUserById, example based on the code you posted: function…
-
3
votes1
answer185
viewsA: Radiobutton in flutter with error
You created your Widget the wrong way: class Radiobutton extends StatefulWidget { @override RadioButtonWidget createState() => RadioButtonWidget(); } class RadioButtonWidget extends…
-
2
votes3
answers392
viewsA: How to use reduce in an object array in React
Initially I recommend a reading on How to Not Ask Questions in Stack Overflow, I will answer the same according to what I understood by the title of the question using the method reduce to add the…
-
0
votes1
answer30
viewsA: How to get value from a function that is within the other JS function
Initially reserve a minute of your time to read about Javascript Promises will help you a lot. There are a few ways to solve your problem, but the simplest and most beautiful would be to put…
-
0
votes2
answers67
viewsA: Compare changed values in object array
If you need a Generic mode simply to know if there has been any change in the object, you can turn it into a String and then compare the value of the Strings, example: JSON.stringify(valorAtual) ===…
javascriptanswered Leo Letto 3,303 -
1
votes2
answers117
viewsA: How to use while in javascript
I believe you need to initially reread your own code and look for errors that are obvious, for example: Uncaught Referenceerror: Data is not defined at Object.Success This mistake is telling you…
javascriptanswered Leo Letto 3,303 -
0
votes1
answer33
viewsA: Filter with 2 Object Array
To do this you need to check for each element of A if the same exists within B, you can do it in several ways, a simple would be using the Find Index, basically for each value in A you search for…
javascriptanswered Leo Letto 3,303 -
3
votes1
answer39
viewsA: Filter in the null returning array
This is because STATUS is an array of objects with within their status, and you are iterating on this array and not on the object values of it, if you know that their values exist within the first…
-
0
votes2
answers322
viewsA: Why the function returns the Undefined value
Instead of checking the condition valido != [], you should actually check that property length array indicating how many elements this array contains, example: if (valido.length > 0){ return…
-
0
votes2
answers37
viewsA: Balance calculation (Credit - Debit) resulting in Nan
You need to keep your code simple, the concept of creating functions serves exactly so that you divide your code into small pieces that can be used in a generic way in various parts of your program,…
-
0
votes1
answer42
viewsA: Perform sum of value to insert into an object
Its function createTransaction should also be concerned with updating the balance user with the new value just entered instead of having to iterate the array each time to update the value, you could…
javascriptanswered Leo Letto 3,303 -
2
votes2
answers49
viewsA: Doubts about usability - var e functions - Javascript
This depends on the programmer and how clean you want your program to be, for example: A function that checks a condition and updates a part of the HTML In this case your approach would be the…
-
2
votes1
answer132
viewsA: How to recover firebase keys? Javascript
Sometimes it is not even necessary to consult the documentation, you have already tried to make a console.log(item) just to know what’s inside? Inside you must find the key item.payload.doc.id which…
-
0
votes2
answers928
viewsA: FLUTTER ERROR - The method '[]' was called on null
Apparently your widget is being built faster than the API response time, and your initState does not expect an API response. That is why Futurebuilder you need to show a loading screen or "nothing"…
-
2
votes1
answer652
viewsA: How to "type" nested objects? (Typescript)
If you are using typescript and want to make a better use of types, especially for objects, the best thing to do is to use an interface, example: interface MinhaInterface{ car: { full: string,…
-
0
votes1
answer34
views -
2
votes2
answers61
viewsA: Execute method only if there is specific property in the object. No testing each line with hasOwnProperty() or comparing with Undefined
A solution would iterate through the keys of this object if you want to run some checks on each key, example: const dados = { nome: "Diego", sobrenome: "Henrique", idade: "22" } const keys =…
javascriptanswered Leo Letto 3,303 -
0
votes5
answers266
viewsA: How to create a function that repeats a certain value
An alternative solution, and I believe it to be simpler, would be to create an array and fill in the same with the desired value, and return a Join similarly so that it is not necessary to…
-
1
votes1
answer15
viewsA: Problems with concatenations using jQuery, to insert parameters with append
Take a minute of your time to read about Interpolation is very simple and makes your code more readable, example: const filme = { title: "I'm a movie", description: "That's my story", release: 2020,…
-
0
votes1
answer135
viewsA: How do I print the amount of times an array item appears
Your code does one thing but your question says something else, anyway I will demonstrate some ways to solve what I believe to be your problem, this is our array of notes notas = [1,1,3,3,5,5], its…
javascriptanswered Leo Letto 3,303 -
0
votes2
answers87
viewsA: How to use rowCount to limit the number of records in a postgresSQL database using Node js?
I recommend that you make use of modules to make your life easier by working with nodejs, and look for a package for postgree that works with promises. Suppose you have a file called DB.js done as…
-
2
votes1
answer177
viewsA: Is there any way to simplify my structure? if yes how
It depends on your definition of "simplify", which is simple for me may not be simple for you, here is my solution to your problem which I believe is "simple". You will need methods like Math.min…
-
0
votes1
answer88
viewsA: How to show the name of all arrays inside an object?
Your problem is here: item.localizacoesFilho[0] You are only taking the first element of it (0) and comparing, what you need is to iterate through all the objects within a localizacoesFilho and…
-
2
votes3
answers231
viewsA: Problem Solving in Javascript
You receive input into this function an array that is done in this mode: [idade, altura] You can do something simple like: function maiorAlto(usuario){ return (usuario[0] >= 18 &&…
-
1
votes3
answers1280
viewsA: Develop a function that concatenates elements of the same position in different arrays according to a given condition
Your solution is partially correct, but there are several errors that must be corrected. Starting from the most basic, in any programming language, the numbers start from 0, so when I ask you for…
-
3
votes4
answers876
viewsA: How to capitalize all words in an array using toUpper?
If you want to make a copy of it, you can use the map, example: var min = ["arroz", "blusa", "lápis"]; var mai = min.map(p => p.toUpperCase()); console.log(mai); The function map will scroll…
-
2
votes4
answers500
viewsA: Return array with numbers larger than the reported Javascript
Javascript already brings with it some methods, and when it comes to array you can use the method filter, that will filter the array and return only the elements that check a certain condition,…
-
1
votes1
answer382
viewsA: How to convert integer to a char array or integer array
You can do this in several modes, the simplest would be to convert your number to a String and then apply the method toCharArray, example: int num = 100; // Seu numero String numStr =…
-
1
votes1
answer54
viewsA: error [Object Htmlinputelement]null I just started on the programming do n know q is wrong
What you’re actually doing is adding two HTML elements, but not their values var n1 = document.getElementById('l') in this case n1 it is not the value of your input, but it is an object with a…
-
0
votes1
answer37
viewsA: Picking up new information from a website and adding a new line with this information every time it is updated
From what I see in your code you’re updating the ListView with the amount you just received, by the way you put the code I assume you’re using the StreamBuilder which will rebuild your list each…
-
1
votes2
answers687
viewsA: How to pick up text from a multi-line textfield in a list with one item per line
Let’s say this is your Textfield TextField( keyboardType: TextInputType.multiline, maxLines: 10, ); You can get its value by adding a type controller TextEditingController, or simply by adding a…
-
0
votes1
answer292
viewsA: Flutter : Listview Builder - Text
it is important that you know how to formulate your question, so that it is easy to understand what your need is, anyway let’s see if this can help you: if (dados[index] is Infracao) //AQUI…
-
2
votes1
answer142
viewsA: Change an entire Scaffold body
I’m not sure I understand your problem, but if you need to pass some data from a child widget to a priest, there are different ways to do this, but the simplest is to simply pass a function to the…
-
0
votes2
answers331
viewsA: Javascript, pick a number (zip code) within a city band
I suppose you already have a way to get the value of the cep written in the input and placed in a variable that we will call cep; // Remove tudo da string deixando somente os numeros e converte a…
-
1
votes1
answer1221
viewsA: Error with Map<String, Dynamic> - Cannot recognize String as Dynamic
Even if you have already found a solution to your problem, I will also leave here a proposal to improve your code, and maintain a clean architecture, so that it is easier for you to understand what…
-
0
votes1
answer463
viewsA: Redirect via button to website - Flutter
You can use the URL Launcher to open the URL’s and other applications: FlatButton( onPressed: openURL ) void openURL(){ const url = 'https://answall.com'; if (await canLaunch(url)) { await…
-
1
votes1
answer260
viewsA: How to save given type map or array in firestore?
You cannot directly enter a List of Items in firebase, you first need to convert your items to a Map: class Item { String nome; int quantidade; Item({this.nome, this.quantidade}); Map<String,…
-
0
votes1
answer282
viewsA: pushNavigator - Dart/Flutter
It wasn’t very clear what your problem is, and the code you posted doesn’t help much, anyway as I understand you need to change the icon that appears in the Appbar, so that it allows you to return…
-
1
votes1
answer203
viewsA: Share Variables between PHP files
On all pages you will need to declare / use a SESSION, you must sign in at the beginning of such a page, for this you need to use the following command: session_start(), once logged in, you can…
-
2
votes2
answers91
viewsQ: Join in array creating elements?
We can imagine the following array: var arr = ["a", "b", "c", "d"]; I know I can use the join(", ") to turn it into a type string: "a, b, c, d", but I would like to create an element for each item…
-
5
votes3
answers190
viewsQ: CSS catch siblings before element?
Well basically, I have the following structure, where when the hover is activated in an element, the brothers on the right must receive an exclusive style, while those on the left must receive…
-
0
votes1
answer109
viewsQ: Nodejs multiple url in app.get Express
I have several (practically all) urls, which point to a single page and use the following line to send the file: app.get('*', function(req, res){ res.sendFile(__dirname+'/home.html'); }); But with…