Hello,
I have an array:
var a = [1,1,2,2,3,4,4,5,6,6];
I need to delete all the duplicates, i.e., both pairs of each duplicate so that I am only left with the elements that are unique.
In the example above the result should be 3, 5.
I've tried pushing or splicing to no avail.
Any...
Hello,
I have a script that has three levels of for statements. Right now the end result is that I get returned the last values of each array. What I wish however is to preserve the values of the first and second iterations.
var a = [1,2,3];
var b = ["a","b"];
var c = ["x","y","z"];
for(var i...
Hello,
I will have two arrays of numbers. One will always be a subset of the other. What I want to know is which numbers only appear in the major set and put them in an array:
var a = [1,2,3,4,5,6];
var b = [1,2,3,6];
//result I want: [4,5]
I have tried concatenating a and b and then looking...
Hello,
I have been tearing my hair out on how to solve this. I will have an array of numbers. I'll never know the starting and ending numbers but they will be in order. However, there may be gaps in the order. It is the gaps I am interested in.
Let's say I start with the following array:
var...
Hello,
Is it possible to use the switch statement with inequalities?
For instance, the following does not work.
Tom
var x = 4;
switch(x){
case <5:
alert("do something");
break;
case 5:
alert("do something more");
break;
case >5:
alert("do something really big");
break...
Hello,
I often have to display the elements of an array in an alert box (probably not a good thing on the web but this is for the InDesign program).
When there are many elements this creates an alert box that is so long that one cannot find the bottom in order to dismiss the alert.
Below is a...
I have an array of objects, some of which are duplicates. I need to pare this down so that there are only unique objects.
I can't show these objects here because they are in the InDesign object model. The best I can do is to make an array of arrays, two of which have equal last elements.
The...
Hello,
I want to search through an array to make sure all the elements are the same. If so, I want there to be one alert to the user, not as many alerts as there are elements. But if one or more elements do not meet a condition, I want an alert for each of those elements.
Below is the script...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.