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
console.log("🥪🍅🍍🍑🍓😛😭😬💩"); |
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 debounce = (fn, time) => { | |
let timerId = null | |
return (...args) => { | |
if (timerId) { | |
clearTimeout(timeId) | |
} | |
timeId = setTimeout(() => { | |
fn(...args) | |
}, time) | |
} |
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
// Class | |
class Emitter { | |
constructor (events = []) { | |
this.events = new Map(events) | |
} | |
on (name, cb) { | |
this.events.set(name, [...(this.events.get(name) || []), cb]) | |
return () => this.events.set(name, this.events.get(name).filter(fn => fn !== cb)) |
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
class Thing { | |
constructor(isLiving){ | |
this.isLiving = isLiving; | |
} | |
doSomething() { | |
console.log('doing some') | |
} | |
} |
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 p1 = { | |
name: 'p1', | |
sayHi: function(){console.log('hi')} | |
} | |
function Person(name) { | |
this.name = name; | |
this.sayHi = function(){console.log('hi')}; | |
} |
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 frutas = ['Maçã', 'Banana']; | |
const fruits = ["Maçã", "Manga", "Uva", "Laranja", "Maçã", "Manga", "Banana", "Banana"] | |
console.log('adciona no comeco - unshift') | |
console.log(frutas.unshift('Laranja')) | |
console.log(frutas) | |
console.log('remove no comeco - shift') | |
console.log(frutas.shift()) | |
console.log(frutas) |
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 getNeighboors = (matrix, row,col) => { | |
let isTopBorder = row === 0; | |
let isRightBorder = col === matrix[row].length - 1; | |
let isBottomBorder = row === matrix.length - 1; | |
let isLeftBorder = col === 0; | |
let top = isTopBorder ? row : row - 1; | |
let left = isLeftBorder ? col : col - 1; | |
let bottom = isBottomBorder ? row : row + 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
function reverseString(str) { | |
// Step 1. Create an empty string that will host the new created string | |
var newString = ""; | |
// Step 2. Create the FOR loop | |
/* The starting point of the loop will be (str.length - 1) which corresponds to the | |
last character of the string, "o" | |
As long as i is greater than or equals 0, the loop will go on | |
We decrement i after each iteration */ | |
for (var i = str.length - 1; i >= 0; i--) { |
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 numbersArray = [1, 2, 3, 4]; | |
const logTimesTwo = num => console.log(num * 2); | |
const customForEach = (arr, cb) => { | |
for (let i = 0; i < arr.length; i++) { | |
cb(arr[i]); | |
} | |
} |
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
DROP DATABASE IF EXISTS `concessionaria`; | |
CREATE DATABASE `concessionaria` ; | |
USE `concessionaria`; | |
CREATE TABLE `carros`( | |
`id_do_carro` int(11) NOT NULL AUTO_INCREMENT, | |
`nome` varchar(50) NOT NULL, | |
`cor` varchar(50) NOT NULL, | |
`quantidade_em_estoque` int(11) NOT NULL, | |
`preco` decimal(8,2) NOT NULL, |