Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
how to loop inside '' in javascript

I want to loop inside single quote I have nested loop in my code errors occurs when I try to loop inside the quote

var jsonObj = @json($data);
var borFld = Object.keys(jsonObj);
var all_fields;
var fields_remove = []
var table_id = @json($table_id);

var rows = [];
var htmls = [];
function getFields(){
    var my_fields = [];

    for(keys in jsonObj){
        var item = jsonObj[keys];
        var fields = Object.keys(item)

        htmls +=
        '<tr>'+
            for(list in fields) {
                var myfields =   fields[list]
                all_fields = item[myfields]

            }
        '</tr>'
    }
   // $('#tb_time_sheet tbody').html(htmls)

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I guess you get the data as string of JSON object. You should first parse it so that JS can read it.

const parsedJsonObject = JSON.parse('{"name":"Test"}');

After that you can use it inside for loop. If it is not array of object and key value pair

  1. You can get values by:

    Object.values(parsedJsonObject);

  2. You can get keys by:

    Object.keys(parsedJsonObject);

Then, iterate over keys and get value by:

parsedJsonObject[key]
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!