Skip to content

Add analyzer for resistor-color #13

Closed
@SleeplessByte

Description

@SleeplessByte

This issue is for discussion and assignment for the resistor-color core exercise in the javascript track.

🔗 implementation | mentor-notes | problem-specification


This exercise introduces the student to Arrays as well as showing that you
can export multiple bindings at once. Solutions using an Object will actively be discouraged as speed is not a good reasoning here.

Optimal solution(s)

export const COLORS = [
  'black', 'brown', 'red', 'orange', 'yellow', 'green',
  'blue', 'violet', 'grey', 'white',
];

export const colorCode = color => COLORS.indexOf(color)

Approvable alternatives are:

  • using an arrow function expression

SHOULD comment and disapprove

Cases we SHOULD comment on with this analyzer:

  • Manually doing indexOf
  • A set of conditionals or a switch
  • Using the obscure bind to bind Array.prototype.indexOf

COULD comment (tips)

Cases we COULD comment on with this analyzer:

  • Doing an export with a specifier (at the bottom of the file) can be done export const inline

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions