const details = {
    "personal_details": {
        "name": "Anubhab Das",
        "email": "[email protected]",
        "contact": "+91 957681276",
        "location": "Kolkata, India",
        "links": {
            "LinkedIn": "linkedin.in/anubhab",
            "Twitter": "twitter.com/anubhab",
            "GitHub": "github.com/anubhab"
        },
    },
    "experience": [
        {
            "institution_name": "Textify AI",
            "position": "Software Development Engineer 1",
            "location": "Indore, MP, India (Remote)",
            "duration": "April 2023 - Present",
            "info": "During my full time tenure, I mostly worked on the backend side of things. I Re-factored back-end infra to automatically deploy newly submitted apps using dynamically created python objects. I also Integrated 70+ mini ChatGPT-powered AI applications on Textify App Platform & organized cross-functional meetings with front-end team to discuss API usage & application flow. On the UI side, Designed dashboard app cards, alert screens, custom app UIs, pop-up forms in Figma"
        },
        {
            "institution_name": "Textify AI",
            "position": "Software Development Intern",
            "location": "Indore, MP, India (Remote)",
            "duration": "April",
            "info": "I worked on Machine Learing and backend web development. Built API endpoints to implement app-specific request queueing using SSE (Server-Sent Events) & Redis. I Deployed 24 GB GPT-J model with 6 billion parameters on an AWS EC2 instance for classifying complaints. Then, I also Implemented basic CI/ CD pipelines using GitHub Actions for deploying backend APIs & I also Built multiple demos for client projects spanning Text summarisation, Translation & Question answering."
        }
    ],
    "education": [
        {
            "institution_name": "ABC Institute of Technology",
            "degree_stream": "Computer Science",
            "grade": "9.08",
            "location": "Kolkata",
            "duration": "2018 - 2023"
        }
    ],
    "projects": [
        {
            "title": "Automatic Title Generation from Abstracts of Research Articles",
            "details": "Developed new keyword-guided model by fine-tuning BART and using RAKE to create compact information-dense abstracts to generate specific titles. Used python and huggingface library.",
            "duration": "Dec 2021 – Jul 2022"
        },
        {
            "title": "NoteItNow: A note-taking Express web app",
            "details": "CRUD app with user authentication, data storage in MongoDB & a basic search feature. Used NodeJS, MongoDB, JS tech stack",
            "duration": "Nov 2021"
        },
    ],
    "skills": [
        "MS Word",
        "C++",
        "Python",
        "MongoDB",
        "FastAPI",
        "NodeJS",
        "Natural Language Processing"
    ],
    "achievements_additional_info": [
        "Came 1st in 10th grade",
        "Came 2nd in coding hackathon 2023"
    ]
}

function capitalizeFirstLetter(str) {
    if (typeof str !== 'string' || str.length === 0) {
        return str; // Return the original string if it's not a non-empty string
    }
    return str.charAt(0).toUpperCase() + str.slice(1);
}

// Convert details object from User Details API to a string for each field
function stringify_user_details(details) {
    var details_stringified = {
        "personal_details": "",
        "experience": "",
        "education": "",
        "projects": "",
        "skills": "",
        "achievements_additional_info": ""
    };

    var personal_details = "";
    for (var key in details["personal_details"]) {
        var val = details["personal_details"][key];
        if (key == "links") {
            var links = details["personal_details"]["links"];
            personal_details += "Links:\n";
            var count = 1;
            for (var link_name in links) {
                personal_details += count++ + ". " + link_name + ": " + links[link_name] + "\n";
            }
        } else {
            personal_details += capitalizeFirstLetter(key) + ": " + val + "\n";
        }
    }
    personal_details += "\n";
    details_stringified["personal_details"] = personal_details;

    if (details["experience"].length !== 0) {
        var experience = "";
        var key_mapper = {
            'info': "details",
            'institution_name': "company"
        }
        for (var i = 0; i < details["experience"].length; i++) {
            var exp = details["experience"][i];
            experience += (i + 1) + ". ";
            for (var key in exp) {
                var key1 = key;
                if (key1 in key_mapper) {
                    key1 = key_mapper[key1];
                }
                key1 = capitalizeFirstLetter(key1);
                experience += key1 + ": " + exp[key] + "\n";
            }
            experience += "\n";
        }
        details_stringified["experience"] = experience;
    }

    var education = "";
    for (var i = 0; i < details["education"].length; i++) {
        var exp = details["education"][i];
        education += (i + 1) + ". ";
        for (var key in exp) {
            var key1 = key;
            if (key1 in key_mapper) {
                key1 = key_mapper[key1];
            }
            key1 = capitalizeFirstLetter(key1);
            education += key1 + ": " + exp[key] + "\n";
        }
        education += "\n";
    }
    details_stringified["education"] = education;

    if (details["projects"].length !== 0) {
        var projects = "";
        for (var i = 0; i < details["projects"].length; i++) {
            var exp = details["projects"][i];
            projects += (i + 1) + ". ";
            for (var key in exp) {
                var key1 = key;
                if (key1 in key_mapper) {
                    key1 = key_mapper[key1];
                }
                key1 = capitalizeFirstLetter(key1);
                projects += key1 + ": " + exp[key] + "\n";
            }
            projects += "\n";
        }
        details_stringified["projects"] = projects;
    }

    var skills = details["skills"].join(", ") + "\n\n";
    details_stringified["skills"] = skills;

    if (details["achievements_additional_info"].length !== 0) {
        var achievements_additional_info = "";
        for (var i = 0; i < details["achievements_additional_info"].length; i++) {
            var ele = details["achievements_additional_info"][i];
            achievements_additional_info += (i + 1) + ". " + ele + "\n";
        }
        details_stringified["achievements_additional_info"] = achievements_additional_info;
    }

    return details_stringified;
}

// Concatenate all fields together to form full_candidate_profile
function get_full_candidate_profile(details_stringified) {
    let full_candidate_profile = "PERSONAL DETAILS:\n\n" + details_stringified["personal_details"];

    if (details_stringified["experience"] != "") {
        full_candidate_profile += "WORK EXPERIENCE:\n\n" + details_stringified["experience"];
    }

    full_candidate_profile += "EDUCATION:\n\n" + details_stringified["education"];

    if (details_stringified["projects"] != "") {
        full_candidate_profile += "PROJECTS:\n\n" + details_stringified["projects"];
    }

    full_candidate_profile += "SKILLS:\n\n" + details_stringified["skills"];

    if (details_stringified["achievements_additional_info"] != "") {
        full_candidate_profile += "ACCOMPLISHMENTS, CERTIFICATIONS & ADDITIONAL INFORMATION:\n\n" + details_stringified["achievements_additional_info"];
    }

    return full_candidate_profile;
}

// Execute the functions
// GET details dict. from API
var details_stringified = stringify_user_details(details);
var full_candidate_profile = get_full_candidate_profile(details_stringified);

console.log("details_stringified: ", details_stringified);
console.log("full_candidate_profile", full_candidate_profile); 

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");