JS Assessment for JavaScript flow control knowledge. The exercise consist of a few simple tasks. You are supposed to implement functions, having provided only the function name and purpose.
Your solutions should be placed inside app/flowControl.js file(inside window.flowControlAnswers object).
Write a function that receives one parameter and:
- if the number is divisible by 3, the function should return 'fizz'
- if the number is divisible by 5, the function should return 'buzz';
- if the number is divisible by 3 and 5, the function should return
fizzbuzz
; - if the number is not divisible by 3 nor 5, the function should return that number;
- if parameter is not a number it should return false
Returns number of elements available through iterator
where iterator is a function returning next available element.
If no more element is available iterator
returns null
.
Returns array of numbers between start
(inclusive) and end
(exclusive).
i.e.: forLoop(100,102) => [100, 101]
Returns sum of elements in array. If any element of array is not a number an exception should be thrown with message according to folowing pattern:
Item at index {index} is not a number
i.e. if first element of array is not a number the message should be:
Item at index 0 is not a number
JavaScript basic functions:
http://www.w3schools.com/jsref/
Javascript EcmaScript5 tutorials and more:
https://developer.mozilla.org/en-US/docs/Web/JavaScript
npm install
To run verify jshint:
grunt jshint:default
To start developing unit tests
grunt test:dev
To run tests and static analysis
npm test
Good luck!