var Arr = [];
for (var x = 0; x < ${Arr_CSV}.length; x++) {
var Exists = "Y";
for (var y = 0; y < Arr.length; y++) {
if (${Arr_CSV}[x] == Arr[y]) {
Exists = "N";
break;
}
}
if (Exists === "Y") {
Arr.push(${Arr_CSV}[x]);
}
}
return (Arr);
There are bugs with various javascript commands so I used this logic.
but duplicates are not removed.
Is it also a bug?
function uniq(arr) {
// Flatten the array
var flattenedArr = [].concat.apply([], arr);
// Create an empty object to store unique values
var uniqueObj = {};
// Iterate over each element in the flattened array
for (var i = 0; i < flattenedArr.length; i++) {
var value = flattenedArr[i];
// Check if the value is already in the uniqueObj
if (!uniqueObj[value]) {
uniqueObj[value] = true;
}
}
// Extract the keys of uniqueObj into a new array
var uniqueArr = Object.keys(uniqueObj);
// Convert the keys from strings to actual values
var resultArr = uniqueArr.map(function (key) {
return Number(key);
});
return resultArr;
}
return uniq(${csv})
converted to es5 using chatGPT. executeScript_Sandbox probably works now
That seems to indicate to me that the variables you are using are not in a proper Array format.
Are you able to use the “foreach” kantu command on you your ArrayVariable? If this is an problem then you kanu variable is not an array. Maybe the content looks like an array but is a string.
function uniq(arr) {
// Flatten the array
var flattenedArr = [].concat.apply([], arr);
// Create an empty object to store unique values
var uniqueObj = {};
// Iterate over each element in the flattened array
for (var i = 0; i < flattenedArr.length; i++) {
var value = flattenedArr[i];
// Check if the value is already in the uniqueObj
if (!uniqueObj[value]) {
uniqueObj[value] = true;
}
}
// Extract the keys of uniqueObj into a new array
var uniqueArr = Object.keys(uniqueObj);
return uniqueArr;
}
return uniq(${csv})