Tag: arrays

Jquery – Create an array from a delimited string and then evaluate its values

i’ve this problem i’m not really able to solve. i have this string “B01, B20, B03, “ i would like to create a jQuery array off this string using the “,” as delimiter then remove the last element ( that would be blank ) and then for each value of the array make an alert. […]

this.each not iterating through collection correctly

I’ve just started using backbone.js and I’m adding some basic methods to extend a collection allowing me to iterate through a collection and save all models, and iterate through a collection to destroy all models. I realise that bulk updates aren’t RESTful, but I’m only updating to local storage so didn’t think it would be […]

How to convert csv to array

I am trying to convert csv to array on angular 1.5+ionic on hebrew. I am using ng-csv. What I done till now: Html: <ng-csv-import class=”import” content=”csv.content” header=”csv.header” header-visible=”csv.headerVisible” separator=”csv.separator” separator-visible=”csv.separatorVisible” result=”csv.result” encoding=”csv.encoding” encoding-visible=”csv.encodingVisible”></ng-csv-import> my controller is : .controller(‘SettingsCtrl’, function ($scope,$parse) { $scope.csv = { content: null, header: true, headerVisible: true, separator: ‘,’, separatorVisible: true, result: […]

Get max values from each array of objects

So I have data like this: data = [ [{a: “b”, value: 12}, {a: “bb”, value: 39}, {a: “bb”, value: 150}], [{a: “c”, value: 15}, {a: “cc”, value: 83}, {a: “ccc”, value: 12}], [{a: “d”, value: 55}, {a: “dd”, value: 9}, {a: “dd”, value: 1}] ] I want to get max values of value in […]

Javascript check if items in an array are consecutive

Say I have an array which holds the values [1,2,3,6,7]. How can I check the array to see if it holds 3 consecutive numbers. For example, the array above holds [1,2,3] so this would return false in my function. var currentElement = null; var counter = 0; //check if the array contains 3 or more […]

Reverse array function with one parameter. (JavaScript)

I’m having a problem trying to write a body for a function that recursively reverse an array, but only has one parameter. function ReverseArray(arr) { var i = 0; var j = arr.length – 1; if (i < j) { var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; return ReverseArray(arr); } return arr; […]

Filter array of objects for unique elements

This question already has an answer here: Object comparison in JavaScript [duplicate] 10 answers

How to collect all possible contiguous string concatenations from an array of arrays of strings?

I am trying to find an efficient way to collect all possible contiguous string concatenations from an array of arrays of strings, excluding strings with duplicated parts. Example: var arr = [ [“pq”,”bcd”], [“l”, “ffnn”, “xyz”], [“hm”, “ffnn”,”ij”], [“ab”,”def”,”u”,”eeff”] ]; function f(a) { var t = []; a[a.length-4].forEach(function(i) { a[a.length-3].forEach(function(j) { if (j !== i) […]

get object key value base on dynamic data

This question already has an answer here: Dynamically access object property using variable 9 answers

Cartesian product without duplicates

I am using a cartesian product function that given [1], [1,2,3], [1,2,3] returns 9 combinations: [ [ 1, 1, 1 ], [ 1, 2, 1 ], [ 1, 3, 1 ], [ 1, 1, 2 ], [ 1, 2, 2 ], [ 1, 3, 2 ], [ 1, 1, 3 ], [ 1, 2, 3 […]