Sha256: 62a7a5b6ea9446609d0ae8ad6ca4992976b4d21a99fed2a1609238dabeafa45a
Contents?: true
Size: 873 Bytes
Versions: 141
Compression:
Stored size: 873 Bytes
Contents
'use strict'; function Allergies(allergenIndex) { this.allergenIndex = allergenIndex; } Allergies.possibleAllergies = [ 'eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']; Allergies.prototype = { list: function () { var possibleAllergies = Allergies.possibleAllergies; var allergicTo = []; for (var i = 0; i < possibleAllergies.length; i++) { var allergy = possibleAllergies[i]; if (this.allergenIndex & Math.pow(2, i)) { allergicTo.push(allergy); } } return allergicTo; }, allergicTo: function (food) { var isAllergic = false; var allergyList = this.list(); for (var i = 0; i < allergyList.length; i++) { if (allergyList[i] === food) { isAllergic = true; break; } } return isAllergic; } }; module.exports = Allergies;
Version data entries
141 entries across 141 versions & 1 rubygems