Skip to content

Instantly share code, notes, and snippets.

View sandrabosk's full-sized avatar
👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall

Aleksandra Bošković sandrabosk

👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall
  • Ironhack
View GitHub Profile

Coding challenge: The recycling game

Instructions

From the array of given trash, make sure every item goes into the right bin. If an item happens to be dirty, it should go to the generic bin, regardless of material.

Here is the array of trash:

Coding challenge: Concat first/second diagonal

Instructions

Iteration 1

From a two dimensional array (with the same height and width), extract and concat all the elements from the "first diagonal", starting from the top left corner to the bottom right corner.

function concatFirstDiagonal(twoDimArray) {
 // your code goes here
const myRover = {
// position is an array of 2 elements -> first element is x and the second element is y
position: [0,0],
direction: 'N',
roverDirections: ['N', 'E', 'S', 'W'],
theCommands: ['f', 'b', 'l', 'r']
};
const theCommands = prompt ("Insert the instruction: ");
class Chronometer {
constructor() {
this.currentTime = 0;
this.intervalId = 0;
}
startClick() {
this.intervalId = setInterval(() => this.currentTime++, 1000);
}

Use destructuring assignment with the rest operator to perform an effective Array.prototype.slice() so that arr is a sub-array of the original array source with the first two elements omitted.

const source = [1,2,3,4,5,6,7,8,9,10];

function removeFirstTwo(list) {
  // your code goes here
}

const arr = removeFirstTwo(source);
const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
// change code below this line
const [a,b,...arr] =list // change this
// change code above this line
return arr;
}
const arr = removeFirstTwo(source);

ES6 basics and a bit more

Concepts we will cover are related to variable:

  • scope,
  • updating,
  • redeclaring and
  • hoisting.

var vs let and const

const usersArray = [
{
firstName: 'Kirby',
lastName: 'Doyle',
id: 'b71794e5-851e-44b5-9eec-1dd4e897e3b8',
isActive: false,
balance: '$3,570.06',
gender: 'male'
},
{

MongoDB and NoSQL

Intro to NoSQL

NoSQL DB is a database used to manage huge sets of unstructured data, where the data is not stored in tabular relations like relational databases.

NoSQL Database Types

Following are the NoSQL database types:

  • Document databases: In this type, key is paired with a complex data structure called document. Example: MongoDB;

Mongo data modeling

2 ways of structuring relationships between documents

Embedded data models

 // user
  {
 _id: ObjectId('5d6f72b128f00f5856e04703'),