const countries = ['SPA El-KENDI INDUSTRIE DU MEDICAMENT',
  'ESKAYEF PHARMACEUTICALS LIMITED',
  'THE WHITE HORSE PHARMACEUTICALS LTD.',
  'Rudolf Lietz Inc.',
  'CHEMO AG',
  'M.P.I Pharmaceutica Gmbh',
  'World Medicine ILac San. Ve. Tic. A.S.',
  'PT. CHEMCO PRIMA MANDIRI',
  'Kusum Healthcare Pvt. Ltd',
  'GENERAL PHARMACEUTICALS LTD.',
  'LIPTIS FOR PHARMACEUTICALS AND MEDICAL',
  'LATAM SALES LLC',
  'Pioneer Co. for Pharmaceutical Industries,',
  'Jerusalem Pharmaceuticals Co.',
  'j-s Co. Werteks',
  'South Egypt Drug Industries Co. (SEDICO)',
  'United Pharmaceuticals',
  'ACME FORMULATION PVT. LTD.',
  'Fideschem Inc',
  'Navana Pharmaceuticals Ltd',
  'INIST Pharm Co., Ltd.',
  'Laboratorios Pharmedic Activa S.A.',
  'BAL PHARMA LIMITED.,',
  'PULSE PHARMACEUTICALS PVT. LTD.',
  'SelectChemie AG',
  'GALPHA LABORATORIES LIMITED',
  'KSV HEALTHCARE LIMITED',
  'Eskayef  Pharmaceuticals Limited',
  'Laboratorios Teramed, S.A. DE C.V.,',
  'LINGRENT CO., LTD',
  'Zim Laboratories Limited',
  'Gencor Pacific Limited,',
  'BENDISON PHARMACEUTICALS PTE LTD.',
  'Andenex - Chemie',
  'CELOGEN PHARMA PVT. LTD.',
  'SHAPHACO PHARMACEUTICAL  INDUSTRIES',
  'Molecules India',
  'DROMEX INTERNATIONAL SL,',
  'BOSTON VIETNAM PHARMACEUTICAL JOINT STOCK CO.,',
  'AURACARE PHARMA PRIVATE LIMITED',
  'DLS Pharmag DMCC',
  'GONOSHASTHAYA PHARMACEUTICALS LTD.,',
  'ORBIT LIFESCIENCE PVT. LTD.',
  'Sedanah Trading Company',
  'ANPHARMA PHARMACEUTICAL COMPANY LIMITED',
  'HOAI PHUONG PHARMACEUTICAL CHEMICAL COMPANY',
  'MEDI PHARMA DRUG HOUSE',
  'LABORATOIRES PHARMACARE',
  'EMIL PHARMACEUTICAL INDUSTRIES PRIVATE LIMITED.',
  'AXXO Im-und Export GmbH',
  'JSC «Canonpharma production»',
  'Qugen Inc.',
  'SPA El-Kendi Pharmaceutical Manufacturing Company',
  'KUSUM HEALTHCARE PVT LTD',
  'Renata Limited',
  'AuraCare Pharma Pvt Ltd',
  'LLC OZON',
  'INTERLUDE CO. SERVICE S.A',
  'National Pharmaceutical Industries Co. (SAOC),',
  'EMIL PHARMACEUTICALS IND PVT LTD',
  'BAL PHARMA LIMITED-UNIT-I-BENGALURU',
  'Galpha Laboratories Ltd - Unit 1',
  'ALLIED GLOBAL LLP',
  'ZISKA PHARMACEUTICALS LIMITED.',
  'Deurali-Janta Pharmaceuticals Pvt. Ltd.',
  'Himont Pharmaceuticals Pvt Ltd',
  'DOCTOR TIMS Pharmaceuticals Ltd.',
  'Goodman Pharmaceuticals Ltd.',
  'ANWITA DRUGS & CHEMICALS PVT. LTD.',
  'PSYCHOTROPICS INDIA LIMITED',
  'ACME FORMULATION PVT. LTD.  GENERAL BLOCK',
  'Med pharm Research Labs',
  'Laboratorios Beta SA',
  'General Pharmaceuticals Ltd,',
  'PHARMANEER DRUGS  INC.',
  'SPA EL-Kendi Pharmaceutical Manufacturing Company',
  'SPA SOPRODIM',
  'Pt. Chemco Prima Mandiri',
  'GROWENA IMPEX COMPANY',
  'National Pharmaceutical Industries Co. ( SAOC)',
  'Jazeera Pharmaceutical Industries',
  'Hizon Laboratories Inc',
  'Dresden Lab S.A.C',
  'INTERLUDE CO. SERVICE S.A',
  'Medgensys Laboratories Pvt Ltd,',
  'SPA El-Kendi Industrie DU Medicament',
  'SPA El-Kendi Pharmaceutical Manufacturing Company',
  'Kuwait Saudi Pharmaceutical Ind. Co.',
  'ACME FORMULATION PVT LTD',
  'GLOBAL PHARMA HEALTHCARE PVT. LTD.',
  'Medisorb AO',
  'Medibios Laboratories Limited.,',
  'AXXO IM-UND EXPORT GMBH',
  'INNOVISION PHARMA',
  'ELOGE FRANCE VIETNAM PHARMACEUTICAL',
  'CIRON DRUGS & PHARMACEUTICALS PVT. LTD.',
  'LIPTIS EGYPT FOR PHARMACEUTICALS AND MEDICAL',
  'FLAGSHIP BIOTECH INTERNATIONAL PVT. LTD.',
  'Brawn Laboratories Limited,',
  'SOCIETE ARABE DES INDUSTRIES PHARMACEUTIQUES',
  'BAL PHARMA LIMITED-UNIT-I-BENGALURU',
  'RANBAXY (MALAYSIA) SDN. BHD.',
  'ORIENT PHARMACEUTICAL CORPORATION',
  'ACME FORMULATION PVT LTD',
  'OPV PHARMACEUTICAL JOINT STOCK COMPANY',
  'INIST PHARM CO. LTD',
  'Sterling Lab (Hosur)',
  'Excellent Joy Ltd.,',
  'Chong Dah Pharmaceutical Co., Ltd.,',
  'CARPE SCHEIDER Y CIA .S.A',
  'The White Horse Pharmaceuticals Ltd.,',
  'Alcon Biosciences Pvt Ltd',
  'Vital Pharma GmbH',
  'Farmatrade S.R.L.',
  'Lek d.d.,',
  'ALQERAT COMPANY FOR TRADING',
  'Yoo-Young Pharmaceutical Co., Ltd',
  'NISHCHEM INTERNATIONAL PVT LTD',
  'BRANCH GLANDCORE COMPANY LIMITED',
  'JSC BIOCOM',
  'Forefront Enterprise Co., Ltd.',
  'Zim Laboratories Ltd.,',
  'PSYCHOTROPICS INDIA LTD.',
  'Kusum  Health care Pvt Ltd',
  'Alphalife Limited',
  'Tricon Enterprises Private Ltd,',
  'GM PHARMACEUTICALS',
  'Vital  Pharma',
  'Gemini Exports',
  'National Pharmaceutical Industries Co. (SAOG),',
  'DPB Antibiotics',
  'Galpha Laboratories Ltd',
  'Deurali-janta Pharmaceuticals Pvt Ltd',
  'Lativ Pharma',
  'Medibios Laboratories Pvt. Limited.,',
  'SKJ Pharmachem',
  'JANET CHEMICAL INC',
  'Pioneer Co. for Pharmaceuticals lndustries,',
  'DVA Health & Nutrition Perú SAC',
  'RV HEALTHCARE PTE. LTD',
  'MEDIPAN SA',
  'GENERAL PHARMACEUTICALS LTD',
  'MEGA INTERNATIONAL PVT LTD',
  'Research -And Production Firm " Microkhim " Ltd',
  'BCM CORPORATION',
  'M.S.J. INDUSTRIES (CEYLON) PVT LTD',
  'Actorverco',
  'R.J.CHEMICALS INC',
  'Biocon Limited',
  'MEGA INTERNATIONAL  PVT  LTD.',
  'BV Pharma Joint Stock Company',
  'AZAL PHARMACEUTICALS INDUSTRIAL CO LTD',
  'Medley Pharmaceuticals Limited-Mumbai',
  'Uttaranchal Biotech Ltd',
  'Rodan Biotech Co. Ltd',
  'SUNGWOO CHEMICAL CO LTD',
  'Golden\xa0Med\xa0Pharma',
  'Forefront Enterprise Co Ltd',
  'CHINA STATE GROUP HOLDINGS LIMITED',
  'SOCIETE TAHA PHARMA DES PRODUITS',
  'Hongkong Sigma Limited',
  'AMOUN PHARMACEUTICAL CO.',
  'Akums Drugs & Pharmaceuticals Ltd (Plant 1-Solid',
  'South Egypt Drug Industries Co (SEDICO)',
  'Kusum  Health care Pvt Ltd (Bhiwadi)',
  'KWANG DONG PHARMACEUTICAL CO. LTD',
  'Xinyi (HongKong) Chemicals Co Ltd',
  'DVA Health & Nutrition Gmbh',
  'Laboratorios Saval S.A',
  'Alcon Biosciences Private Limited,',
  'Index Pharma LLP',
  'SSV Trading Limited,',
  'Sunman-Birdem Pharma Ltd.',
  'MedichemKorea Co Ltd',
  'OOO Trivium - XXI", Russia,',
  'SARL Novapharm Trading',
  'S.C Farmex Company S.R.L.',
  'EGYPTIAN PHARMACEUTICAL & FOOD CHEMICALS',
  'TRENDS EXPORTS PVT LTD',
  'PHARMA TREND KOLL.STI.-ORKHAN ALIYEV VE ORT.',
  'RANBAXY (MALAYSIA) SDN. BHD.',
  'Trivium - XXI',
  'B.T.Gen AG Vienna',
  'Trivium - XXI", Russia,',
  'SJ COMPANY',
  'Janis Med Z.I. IBN Badis',
  'Loghman Pharmaceutical and Hygienic Co.',
  'Jerusalem Pharmaceuticals Co. Ltd.,',
  'MEGA INT. P LTD. - CUSTOMER A/C',
  'Shubham Pharmachem Pvt Ltd',
  'Jayco Chemical Industries',
  'Jazeera Pharmaceutical Industries,',
  'Biesterfeld International Gmbh',
  'Pioneer Co. for Pharmaceutical lndustries,',
  'Fischer Chemicals AG,',
  'Pt. Bahtera Sentra Niagatama Ji.',
  'Sunman Pharmaceuticals Limited',
  'SOUTH EGYPT DRYUG INDUSTRIES CO. (SEDICO)',
  'ALCON BIOSCIENCES PRIVATE LTD',
  'International Trades & Sales Inc',
  'SALUTAS PHARMA GMBH(BARLEBEN)',
  'FISCHER CHEMICALS AG.',
  'JAZEERA PHARMACEUTICAL INDUSTRIES',
  'Majal Pharmaceuticals',
  'SSV TRADING LIMITED',
  'ANADELCO LTD',
  'LANFRANCO TRADING LIMITED',
  'ACTIVA,S.A.DE C.V. /LABORATORIOS PHRMEDIC',
  'GALPHA LABORATORIES LTD - BADDI',
  'THE WHITE HORSE PHARMA(BANGLADESH)',
  'COMMERCIAL LEAGUE SOURCING AG.',
  'TRIWIUM -XXI LTD.',
  'Medical Union Pharmaceuticcals',
  'ALCON BIOSCIENCES (P) LTD-MUMBAI',
  'ANDENEX-CHEMIE (GERMANY)',
  'OPV PHARMACEUTICAL JOINT CO - VIETNAM',
  'CHEMO AG VIENNA BRANCH',
  'FLAMINGO PHARMACEUTICALS LTD.(MUMBAI)',
  'UNITED PHARMACEUTICALS',
  'LAFRANCOL INTERNATIONAL S.A.S. - COLO',
  'INTERNATIONAL TRADES & SALES INC',
  'DEURALI - JANTA PHARMACEUTICALS (P) LTD',
  'POLYDRUG LABORATORIES PVT LTD-MUMBAI',
  'GAVA AIRFARM LOGISTICS FZCO, DUBAI"',
  'BIESTERFELD INTERNATIONAL GMBH',
  'LEK D.D.(LJUBJANA)',
  'PRATI, DONADOZZI & CIA LTDA-BRAZIL"',
  'EGYPTIAN CO. FOR PHARMACEUTICALS & CHEMICALS INDUS',
  'CLEO SINGAPORE PTE LTD',
  'LABORATORIOS JAIME GUTIERREZ',
  'JAZEERA PHARMACEUTICAL INDUSTRIES - S',
  'PHARMA LINKS',
  'HOPERAY INTERNATIONAL CO. LTD',
  'GLOBAL PHARMA CO.LLC(DUBAI)',
  'GLUCOSAMINA S.A.',
  'ACTIVA PHARAM SUPPLIES LTD',
  'UNIFARMA S.A.',
  'STOCKPHARMA AG. - SWITZERLAND',
  'DEXCEL PHARMA TECHNOLOGIES - ISRAEL',
  'OMAN PHARMACEUTICALS PRODUCTS CO. L.L.C.',
  'GRUPO PAILL, SA DE CV',
  'F & A PHARMA- HANDELS GMBH',
  'HIZON LABORATORIES INC.',
  'JERUSALEM PHARMACEUTICALS CO LTD - ISRAE',
  'LABORATORIOS LOPEZ S.A.DE C.V.',
  'GOLGI PHARMACEUTICAL PTD - CYPRUS',
  'TCHAIKA PHARMA HIGH QUALITY MEDICINES INC.',
  'THE UNITED PHARMACEUTICALS MFG CO - JORD',
  'EL KENDI PHARMACUTICAL MANUFACTURING',
  'HEXAL AG.',
  'AADIVIGHNESH CHEM PRIVATE LTD.',
  'ALCON BIOSCIENCES PVT LTD',
  'PT. PARIT PADANG GLOBAL - INDONESIA',
  'MEDIPAN SA T/A MEDICAMENTOS PANAMENOS',
  'METROCHEM API PVT LTD',
  'RICARDO RODRIGUEZ AGUILAR',
  '"NEOPHARMA,MUSSAFAH (UAE)"',
  'NINEVEH FOR PHARMACEUTICALS TRADING.. -',
  'ALPHA PHARMA',
  'UTTARANCHAL BIOTECH LIMITED',
  'MIDDLE EAST PHARMACEUTICAL INDUSTRIES',
  'AMPHARCO U.S.A. PHARMACEUTICAL JOINT'];

countries.sort((a, b) => a.localeCompare(b));

console.log(countries); 

Javascript Online Compiler

Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.

About Javascript

Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.

Key Features

  • Open-source
  • Just-in-time compiled language
  • Embedded along with HTML and makes web pages alive
  • Originally named as LiveScript.
  • Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.

Syntax help

STDIN Example

var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line){
    console.log("Hello, " + line);
});

variable declaration

KeywordDescriptionScope
varVar is used to declare variables(old way of declaring variables)Function or global scope
letlet is also used to declare variables(new way)Global or block Scope
constconst is used to declare const values. Once the value is assigned, it can not be modifiedGlobal or block Scope

Backtick Strings

Interpolation

let greetings = `Hello ${name}`

Multi line Strings

const msg = `
hello
world!
`

Arrays

An array is a collection of items or values.

Syntax:

let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);

Example:

let mobiles = ["iPhone", "Samsung", "Pixel"];

// accessing an array
console.log(mobiles[0]);

// changing an array element
mobiles[3] = "Nokia";

Arrow functions

Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.

Syntax:

() => expression

Example:

const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
                                    .map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);

De-structuring

Arrays

let [firstName, lastName] = ['Foo', 'Bar']

Objects

let {firstName, lastName} = {
  firstName: 'Foo',
  lastName: 'Bar'
}

rest(...) operator

 const {
    title,
    firstName,
    lastName,
    ...rest
  } = record;

Spread(...) operator

//Object spread
const post = {
  ...options,
  type: "new"
}
//array spread
const users = [
  ...adminUsers,
  ...normalUsers
]

Functions

function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
  console.log(`Hello ${name}!`);
}
 
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar

Loops

1. If:

IF is used to execute a block of code based on a condition.

Syntax

if(condition){
    // code
}

2. If-Else:

Else part is used to execute the block of code when the condition fails.

Syntax

if(condition){
    // code
} else {
    // code
}

3. Switch:

Switch is used to replace nested If-Else statements.

Syntax

switch(condition){
    case 'value1' :
        //code
        [break;]
    case 'value2' :
        //code
        [break;]
    .......
    default :
        //code
        [break;]
}

4. For

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
//code  
} 

5. While

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
  // code 
}  

6. Do-While

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
  // code 
} while (condition); 

Classes

ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.

Syntax:

class className {
  constructor() { ... } //Mandatory Class method
  method1() { ... }
  method2() { ... }
  ...
}

Example:

class Mobile {
  constructor(model) {
    this.name = model;
  }
}

mbl = new Mobile("iPhone");