This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let distinct = 0; | |
let sorted = A.sort((a, b) => a - b); | |
let last; | |
// console.log(sorted) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let zeroCount = 0; | |
let combinations = 0; | |
A.forEach((n, index) => { | |
if (n === 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let max = A.length; | |
let total = (max * (max + 1) / 2); | |
let partial = 0; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let sorted = A.filter(a => a >= 1).sort((a, b) => a - b); | |
// console.log('sorted', sorted) | |
let minor = 1; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackblitz.com/edit/rxjs-map-pipe-study-b2qoje | |
import { of, from } from 'rxjs'; | |
import { map, flatMap, catchError } from 'rxjs/operators'; | |
console.clear(); | |
function fakeApiCall(value) { | |
console.log('Calling', value) | |
var lookupValues = { "a": 123, "b": 234, "c": 345, "d": 456 }; | |
throw new Error('Hmmmm we are breaking things!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const secret = (msg) => () => msg; | |
// partialApply(targetFunction: Function, ...fixedArgs: Any[]) => | |
// functionWithFewerParams(...remainingArgs: Any[]) | |
const partialApply = (fn, ...fixedArgs) => { | |
return function (...remainingArgs) { | |
return fn.apply(this, fixedArgs.concat(remainingArgs)); | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const mode = process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'test' ? 'development' : 'production'; | |
const serverConfig = { | |
target: 'node', | |
mode: mode, | |
entry: __dirname + '/src/index.js', | |
devtool: 'inline-source-map', | |
resolve: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="./weather.min.js"></script> | |
</head> | |
<body> | |
<button onclick="showWeather()">Click to know the weather :)</button> | |
<script> | |
function showWeather() { | |
var weather = new Weather(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 1, | |
"name": "sydney", | |
"price": 700 | |
}, | |
{ | |
"id": 2, | |
"name": "london", | |
"price": 600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require the framework and instantiate it | |
const fastify = require('fastify')() | |
const destinations = require('./destinations.json'); | |
// our weather library | |
const Weather = require('weather'); | |
// Declare a route | |
fastify.get('/destinations', async (request, reply) => { | |
reply |