Posts by Sorack • 27,430 points
864 posts
-
2
votes5
answers7032
viewsA: How to return the sum of numbers of an array with indices of value greater than or equal to 2
You can filter and use the reduce function to sum the resulting components: var teste = [0,2,0,0]; function adicionar(a, b) { return a + b; } function somar(array) { return…
-
10
votes7
answers2833
viewsA: How to check if at least one item of the array has value equal to or greater than 2
You can filter and check the size of the resulting array as below: var teste = [0,2,0,0]; function verificar(array) { return array.filter(function(item) { return item >= 2; }).length > 0; }…
-
3
votes1
answer52
viewsA: Javascript - discount from x units
Script missing a lock key, variable elemResult was declared after use and the element resultado had not been defined. The result would be the following: function calcular() { var de =…
javascriptanswered Sorack 27,430 -
2
votes3
answers16786
viewsA: Change object value
Iterating the object and changing the value of the property would look something like this: var objeto = [ { name: '2015', data: [], color: 'orange' }, { name: '2016', data: [], color: 'red' }, ];…
-
3
votes1
answer3762
views -
1
votes2
answers536
viewsA: Service with list of cars and models
There is a FIPE table scraper that can be used as the basis for what you want: https://github.com/Sorackb/FipeReader And in the same repository there is a service of the old site of FIPE that can be…
-
1
votes1
answer139
viewsA: Recover last row inserted in table with non-sequential primary key - Mysql
Add a column with the insertion date: ALTER TABLE tabela ADD insercao DATETIME DEFAULT CURRENT_TIMESTAMP; Or an auto increment id: ALTER TABLE tabela ADD id INTEGER NOT NULL AUTO_INCREMENT;…
-
1
votes2
answers1178
viewsA: Java - Enter function
Use a global control variable, so you can check that this is not the second time ENTER is being squeezed. Shortly after the execution on JOptionpane change again to the default value and the problem…
-
3
votes2
answers268
viewsA: Close button in <Md-select>
Add a ng-click on the button with the following code: $mdSelect.hide(); EDIT 1 You must inject the $mdSelect dependency into the controller statement: angular .module('MyApp', ['ngMaterial'])…
-
1
votes1
answer1068
viewsA: Open Jframe in maximized Java
The problem is that you are centering the frame before centering it. Center it first and then maximize: frame.setVisible(true); frame.setLocationRelativeTo(null);…
-
2
votes1
answer126
viewsA: Error while trying to add updated Fields in Clientdataset
Everything indicates that it is a where or join where you compare a varchar with a inteiro. It can also be the type of parameter you entered in the component. Check if there is parameter, otherwise…
-
1
votes2
answers560
viewsA: How to create shortcut to open a Jmenu?
You can use the class KeyboardFocusManager to capture keyboard events and verify which was the event that triggered it: KeyboardFocusManager .getCurrentKeyboardFocusManager()…
-
2
votes1
answer1698
viewsA: Routes in separate files
You can separate the routes by file. To do this create a new Router in the new archive and refer to your main route archive: app js. const express = require('express'); const app = express.Router();…
-
3
votes1
answer57
viewsA: Doubt About Socket logic
Yes, you can use inherited classes to determine what type of socket, but in the case you described it might be simpler if you just create two list variables in the server class as follows: private…