function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

for loop not working in lightning js controller

Hi ,
how to iterate all the value in for loop , but below code has been ovverite old values and latest values printing , how to avoid overrite in for loop ?

var strgrpname = event.getParam("strgroupname");  ex: first time "Test1" , second time "Test2" , third time "Test3"
var strname = [];
         for(var strbal  in strgrpname ){
          strname .push(strbal);      
component.set("",strname ) ;
console.log('pirnt-->'+component.get("" )); result : Test3 .
Hi Ramakrishana
please try this code
var strgrpname =event.getParam( "strgroupname");
var strname=[];
for each (var item in strgrpname){
if this answer is useful for you please choose best answer
let me know if any hlep you regading this code: