Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.48 KB

the-office-ii-boredom-score.md

File metadata and controls

63 lines (51 loc) · 1.48 KB

The Office II - Boredom Score 7 Kyu

LINK TO THE KATA - ARRAYS FUNDAMENTALS

Description

Every now and then people in the office moves teams or departments. Depending what people are doing with their time they can become more or less boring. Time to assess the current team.

You will be provided with an object(staff) containing the staff names as keys, and the department they work in as values.

Each department has a different boredom assessment score, as follows:

accounts = 1
finance = 2
canteen = 10
regulation = 3
trading = 6
change = 6
IS = 8
retail = 5
cleaning = 4
pissing about = 25

Depending on the cumulative score of the team, return the appropriate sentiment:

<=80: 'kill me now'
< 100 & > 80: 'i can handle this'
100 or over: 'party time!!'

Solution

const pairs = {
  accounts: 1,
  finance: 2,
  canteen: 10,
  regulation: 3,
  trading: 6,
  change: 6,
  IS: 8,
  retail: 5,
  cleaning: 4,
  'pissing about': 25,
}

const boredom = staff => {
  const boredomValues = Object.values(staff)
  const boredomScore = boredomValues.reduce(
    (accumulator, currentValue) => accumulator + pairs[currentValue],
    0,
  )

  return boredomScore <= 80
    ? 'kill me now'
    : boredomScore < 100 && boredomScore > 80
    ? 'i can handle this'
    : 'party time!!'
}