Skip to content

Instantly share code, notes, and snippets.

View ukhlivanov's full-sized avatar

Sergey Ukhlivanov ukhlivanov

  • Philadelphia, PA
View GitHub Profile
//Get all
db.restaurants.find();
//Limit and sort
db.restaurants.
find({borough: "Manhattan"}, {_id: 1, name: 1, address: 1}).
sort({name: 1}).
limit(10);
//Get by _id
const express = require("express");
const app = express();
// your code here!
app.get("/echo/:what", (req, res) => {
res.json({
hostname: req.hostname,
query: req.query,
what: req.params
@ukhlivanov
ukhlivanov / gist:82a3a377e0eb0fd60c7908884fa1164d
Last active June 18, 2018 00:49
High Level Definition of My App Idea
Helps user to find interesting events and provide cost and travel time to the destination along with Uber,
the trip price will be displayed in several currencies.
List of API's:
1.Get the latest foreign exchange reference rates. GET https://exchangeratesapi.io/api/latest HTTP/1.1
2.https://maps.googleapis.com/maps/api/
3.Meetup API https://api.meetup.com/find/groups
4.Uber API https://api.uber.com/v1
@ukhlivanov
ukhlivanov / Cat carousel
Created May 11, 2018 00:28
Thinkful(Events)
@ukhlivanov
ukhlivanov / mostFrequentWord
Created May 4, 2018 04:11
ThinkFul(read code)
function getTokens(rawString) {
// Returns array of strings, with lower case, spaces and ,!.";:- - these simbols will be deleted
//regardless of how many times they were repeated and will be removed any falsy items from an array
// the array will be sorted alphabetically. As a result, an array of words is returned in the alphabetical order.
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {
@ukhlivanov
ukhlivanov / Find by id
Created May 4, 2018 01:36
ThinkFul-Objects
// you can pass in `scratchData` to test out `findByid`
// your function
const scratchData = [
{ id: 22, foo: 'bar' },
{ id: 28, foo: 'bizz' },
{ id: 19, foo: 'bazz' },
];
function findById(items, idNum) {
// your code here
@ukhlivanov
ukhlivanov / Create
Created May 3, 2018 18:39
ThinkFul-Objects
function createMyObject() {
// your code here
const myObject={
foo: 'bar',
answerToUniverse:42,
'olly olly':'oxen free',
sayHello: function(){
return 'hello';
},
};
What is scope? Your explanation should include the idea of global vs. local scope.
Scope refers to the visibility of variables. Global variable will be avialable everywhere in program. The local variable will only be available in the code block where it was defined (for example: class or function). When you define a variable in a function that has the same name as a variable in the global scope, the local variable will take precedence over the global one.
Why are global variables avoided?
Global variables are hard to use together with other developers. A global variable can be changed to any part of the program and therefore it is difficult to control it especially in a large application.
Explain JavaScript's strict mode.
When strict mode is enabled all variables should be declared(for example let myVar="myVar"), for variables without declaration error will be triggered. The command "use strict" can be put at the top of file to enforce strict mode, or at the top of functionб, in this case, strict mode will
function fizzBuzz(countTo) {
// your code here
const arr=[];
for(let i=1; i<=countTo; i++){
if((i%3 === 0) && (i%5 === 0)){
arr.push("fizzbuzz");
} else if(i%3 === 0){
arr.push("fizz");
}else if(i%5 === 0){
@ukhlivanov
ukhlivanov / ThinkFul-Arrays(Filter)
Created April 30, 2018 01:12
ThinkFul-Arrays 2
function shortWords(array) {
// your code goes here
const myArray = array.filter(word => word.length < 5);
return myArray;
}
/* From here down, you are not expected to
understand.... for now :)