let data = [{"questiontext":"Dear Customer, we appreciate you taking time to tell us about your visit. This information will be held in strictest confidence and only be used to improve your experience and our standard of care. How likely are you to refer Apollo Clinics to your friends, relatives or colleagues?","id":1},{"questiontext":"Thankyou, Please confirm If you wish to give a detailed feedback","id":2},{"questiontext":"How did you come to know about Apollo Medical Centre?","id":3},{"questiontext":"Will you consider this clinic as your regular source of care ?","id":4},{"questiontext":"How would you rate the ease of getting an appointment?","id":5},{"questiontext":"How would you rate Cleanliness and ambience of the clinic?","id":6},{"questiontext":"How would you rate Time taken at billing?","id":7},{"questiontext":"How would you rate Waiting time to see the doctor ?","id":8},{"questiontext":"How would you rate Your experience with the doctor and explanation about the diagnosis, treatment, follow up and referrals?","id":9},{"questiontext":"How would you rate us on the ease of getting an appointment for investigations and procedures?","id":10},{"questiontext":"How would you rate us on the waiting time for investigations and procedures?","id":11},{"questiontext":"Were the reports ready at the committed time?","id":12},{"questiontext":"How would you rate the following on their courteousness of Nurses?","id":13},{"questiontext":"How would you rate the following on their courteousness of Phlebotomist (blood collection)?","id":14},{"questiontext":"How would you rate the following on their courteousness of Radiology technicians?","id":15},{"questiontext":"How would you rate the following on their technical expertise - Nurses?","id":16},{"questiontext":"How would you rate the following on their technical expertise - Phlebotomist (blood collection)?","id":17},{"questiontext":"How would you rate the following on their technical expertise - Radiology technicians?","id":18}]
let data2 = [{"id":1,"questiontext":"Dear Customer, we appreciate you taking time to tell us about your visit. This information will be held in strictest confidence and only be used to improve your experience and our standard of care. How likely are you to refer Apollo Clinics to your friends, relatives or colleagues?","wabanumber":"919921449959","rating":6,"createdt":"2023-03-27 14:39:50","mobileno":"917276314872"},
{"id":2,"questiontext":"Dear Customer, we appreciate you taking time to tell us about your visit. This information will be held in strictest confidence and only be used to improve your experience and our standard of care. How likely are you to refer Apollo Clinics to your friends, relatives or colleagues?","wabanumber":"919921449959","rating":2,"createdt":"2023-03-27 14:39:50","mobileno":"917276314872"}]

let questionnoarr = [];

for (let i = 0; i < data.length; i++) {
  let ratingObj = {};
  ratingObj.id = data[i].id;

  for (let j = 0; j < data2.length; j++) {
    if (data[i].id === data2[j].id) {
      ratingObj.rating = data2[j].rating;
      break;
    }
  }

  if (!ratingObj.rating) {
    ratingObj.rating = "";
  }

  questionnoarr.push(ratingObj);
}

console.log(questionnoarr); 

NodeJS Online Compiler

Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json.

About NodeJS

Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.

Key features

  • Built on Google chrome's javascript engine V8 and is pretty fast.
  • Node.js was developed by Ryan Dahl in 2009.
  • Server-side platform for building fast and scalable applications.
  • Node.js is Asynchronous, event-driven and works on single-thread model thus eliminating the dis-advantages of multi-thread model.
  • Supports various platforms like Windows, Linux, MacOS etc.
  • Provides rich library of java script modules which simplifies the development efforts.
  • Released under MIT license.

Express Framework

Express is one of the most popular web application framework in the NodeJS echosystem.

  • Pretty fast
  • Minimalist
  • Unopinionated
  • Very flexible

Syntax help

Examples

Using Moment

let moment = require('moment');

console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));

Using Lodash

const _ = require("lodash");

let colors = ['blue', 'green', 'yellow', 'red'];

let firstElement = _.first(colors);
let lastElement = _.last(colors);

console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);

Libraries supported

Following are the libraries supported by OneCompiler's NodeJS compiler.

  • lodash
  • moment
  • underscore
  • uuid
  • ejs
  • md5
  • url