How to grouping variable and create multidimensional array in jquery -


i have list of variable inside array :

  • a = mango
  • b = potato
  • c = peach
  • d = grape
  • a = mango, potato
  • a = potato, banana

how create array in jquery , concat same variable , remove duplicate data when founds in same variable?

expected results :

[b=> "potato", c => "peach",d=>"grape", a=>"mango, potato,banana" ]

thanks

this function give {b=> "potato", c => "peach",d=>"grape", a=>["mango", "potato","banana"]}

$(function () { $('#btnclick').click( function(){

    var array={};     var =[];             a.push("mango")     a.push("apple")     a.push("mango")      = $.unique(a);     var val = "";     (var = 0; < a.length; i++) {       val += a[i] + ",";     }     val = val.slice(0, -1) //remove last comma     alert(val);       array.a=a;      array.b="potato";       array.c="peach";        array.d="grape";     }); }); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -