How close are you to the role?

A skill-gap check compares what you know with what a role asks for, and turns the gap into a study list.

What to build

Compare a learner's skills with several roles.

Requirements

  • Line 1: the learner's skills, comma-separated. Each remaining line is role: skill1, skill2, ....
  • For each role print role: P% (learn: a, b), where P is the rounded percentage of its skills the learner has, and the learn list is the missing skills in the role's order. If nothing is missing, print role: 100% (ready).

Input

As described.

Output

One line per role.

Constraints

Up to 30 roles with up to 15 skills each. Skill names have no commas.

Example

Input:

networking, linux, python, web-security
SOC analyst: networking, linux, log-analysis, incident-response
Penetration tester: networking, linux, web-security, scripting, report-writing

Output:

SOC analyst: 50% (learn: log-analysis, incident-response)
Penetration tester: 60% (learn: scripting, report-writing)

Why it works

The share of a role's skills you already have measures how close you are, and the missing skills in order are a ready-made plan of what to learn next.

Examples

Example 1 · Input
networking, linux, python, web-security
SOC analyst: networking, linux, log-analysis, incident-response
Penetration tester: networking, linux, web-security, scripting, report-writing
Expected output
SOC analyst: 50% (learn: log-analysis, incident-response)
Penetration tester: 60% (learn: scripting, report-writing)
Example 2 · Input
python
Developer: python
Expected output
Developer: 100% (ready)

Hints

Hint 1

Math.round((have / total) * 100) gives the rounded percentage.

Solution

Show one correct solution (try it yourself first)
const mine = new Set(prompt().split(",").map((s) => s.trim()).filter(Boolean));
let line = prompt();
while (line !== null) {
  if (line.trim()) {
    const at = line.indexOf(":");
    const role = line.slice(0, at).trim();
    const needs = line.slice(at + 1).split(",").map((s) => s.trim()).filter(Boolean);
    const missing = needs.filter((s) => !mine.has(s));
    const pct = Math.round(((needs.length - missing.length) / needs.length) * 100);
    console.log(missing.length ? `${role}: ${pct}% (learn: ${missing.join(", ")})` : `${role}: 100% (ready)`);
  }
  line = prompt();
}

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: Security careers and a learning roadmap →