Hello, checkiomates🐱👤!
This week, we stock up on JavaScript algorithms from a comprehensive GitHub repository, learn about the new Invokers API for codeless interactivity in the browser, and visualize complex TypeScript types with an online tool. Our mission is to program the classic "FizzBuzz" game to teach robots about division and modular arithmetic.
💡TIP
At every mission page, under the editor window, there is a terminal window. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁MISSION
"Fizz buzz" is a word game we will use to teach the robots about division. You should write a function that will receive a positive integer and return: "Fizz Buzz" if the number is divisible by 3 and by 5; "Fizz" if the number is divisible by 3; "Buzz" if the number is divisible by 5; The number as a string for other cases.
assert.strictEqual(fizzBuzz(15), "Fizz Buzz"); assert.strictEqual(fizzBuzz(6), "Fizz"); assert.strictEqual(fizzBuzz(10), "Buzz"); assert.strictEqual(fizzBuzz(7), "7");
📖ARTICLES
Over 150 Algorithms and Data Structures Demonstrated in JS -
Examples of many common algorithms (e.g. bit manipulation, Pascal’s triangle, Hamming distance) and data structures (e.g. linked lists, tries, graphs) with explanations. Available in eighteen other written languages too.
What are 'Invokers': Interactivity without JavaScript? -
The Invoker Commands API lets you assign behaviors to buttons. You can use JavaScript to create custom commands, however.
TSDiagram: Diagrams as Code with TypeScript -
Draft diagrams quickly with TypeScript. Define your data models through top-level type aliases and interfaces and it automatically lays out the nodes in an efficient way.
👩💻CODE SHOT
What do you think the following code does?
function checkio(items: number[]): number[] {
let flag, last = null;
return items.filter(c => (flag = c != last, last = c, flag));
}
🙌 Thanks for your attention! Hope to meet you at CheckiO, as well as at our Instagram and Twitter! We are really interested in your thoughts! Please, leave a comment below! ⤵
