This file contains 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
//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 |
This file contains 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 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 |
This file contains 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
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 |
This file contains 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
function handledThumbnailClick() { | |
$('.thumbnail').on('click', function(event){ | |
let curSrc=$(this).find('img').attr('src'); | |
let curAlt=$(this).find('img').attr('alt'); | |
$('.hero img').attr('src', curSrc).attr('alt', curAlt); | |
}); | |
} | |
$(handledThumbnailClick); |
This file contains 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
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) { |
This file contains 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 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 |
This file contains 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
function createMyObject() { | |
// your code here | |
const myObject={ | |
foo: 'bar', | |
answerToUniverse:42, | |
'olly olly':'oxen free', | |
sayHello: function(){ | |
return 'hello'; | |
}, | |
}; |
This file contains 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
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 |
This file contains 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
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){ |
This file contains 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
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 :) | |