Which property broke?

Incident reports often use the same few verbs. Matching the verb to the property it breaks is the first step in any report.

What to build

Read incident words, one per line, and print which part of the CIA triad each one breaks, then a count for each.

Requirements

  • leaked, read and copied break confidentiality.
  • edited, forged and altered break integrity.
  • down, flooded and locked break availability.
  • Any other word prints unknown and is not counted.
  • After the last word, print C x I y A z with the three counts.

Input

One word per line, in lower case.

Output

One property name per input line, then the counts line.

Constraints

1 to 50 words.

Example

Input:

leaked
edited
down

Output:

confidentiality
integrity
availability
C 1 I 1 A 1

Why it works

Each word belongs to exactly one list, so one lookup per line decides the property, and three counters keep the totals.

Examples

Example 1 · Input
leaked
edited
down
Expected output
confidentiality
integrity
availability
C 1 I 1 A 1
Example 2 · Input
flooded
forged
stolen
Expected output
availability
integrity
unknown
C 0 I 1 A 1

Hints

Hint 1

Keep three arrays of words, or one object that maps each word to its property.

Hint 2

Read with prompt() until it returns null.

Solution

Show one correct solution (try it yourself first)
const property = {
  leaked: "confidentiality", read: "confidentiality", copied: "confidentiality",
  edited: "integrity", forged: "integrity", altered: "integrity",
  down: "availability", flooded: "availability", locked: "availability",
};
let c = 0, i = 0, a = 0;
let word = prompt();
while (word !== null) {
  const p = property[word.trim()] ?? "unknown";
  console.log(p);
  if (p === "confidentiality") c++;
  else if (p === "integrity") i++;
  else if (p === "availability") a++;
  word = prompt();
}
console.log(`C ${c} I ${i} A ${a}`);

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

Lesson: What security protects: the CIA triad →