Skip to content

Commit 819711e

Browse files
authored
Update js codes.docx
1 parent ffa63fb commit 819711e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

js codes.docx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,8 +3232,28 @@ console.log(frequencySort([1,1,2,2,2,3]))
32323232

32333233

32343234

3235+
-------
3236+
Dassault Systems:
3237+
const inputArray = ["INDIA:[Delhi,Mumbai,Chennai]"]; //1
3238+
const extepctedOutputArray = ["INDIA:[Delhi]", "OR", "INDIA:[Mumbai]", "OR", "INDIA:[Chennai]"];
32353239

32363240

3241+
//GENERIC JS FUNCTION --> String with comma will split as separate Items in new ARRAY and separated with OR between each
3242+
3243+
function convertToORBasedExpression (arr){
3244+
var outputArray =[];
3245+
var temp = arr[0].split(":")[1]; //"[Delhi,Mumbai,Chennai]"
3246+
var tmp = temp.slice(1,21).split(",") //["Delhi","Mumbai","Chennai"]
3247+
for (let item of tmp){
3248+
//console.log("INDIA:"+item)
3249+
outputArray.push("INDIA:"+item)
3250+
}
3251+
// console.log(temp.slice(1,21).split(","))
3252+
3253+
return outputArray; //5
3254+
}
3255+
convertToORBasedExpression(inputArray)
3256+
32373257

32383258

32393259

0 commit comments

Comments
 (0)