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 Sequelize = require('sequelize'); | |
const sequelize = new Sequelize('database', 'root', 'password', { | |
host: 'localhost', | |
dialect: 'mysql' | |
}); | |
const Account = sequelize.define('account', { | |
balance: { | |
type: Sequelize.INTEGER, | |
allowNull: false, |
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
var axios = require("axios"); | |
const promises = []; | |
for(i=0;i< 5;i++) { | |
promises.push(callApi()) | |
} | |
let success = 0, error = 0; | |
Promise.all(promises).finally(() => { |
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
/** | |
* A javascript solution Have the function SearchingChallenge(str) take the str parameter being passed and return 1 #ofBrackets if the brackets are correctly matched and each one is accounted for. Otherwise return 0. For example: if str is "(hello [world])(!)", then the output should be 1 3 because all the brackets are matched and there are 3 pairs of brackets, but if str is "((hello [world])" the the output should be 0 because the brackets do not correctly match up. Only "(", ")", "[", and "]" will be used as brackets. If str contains no brackets return 1. | |
**/ | |
function SearchingChallenge(str) { | |
let bracketMaps = { | |
'(': 0, | |
'[': 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
import React, { useState } from 'react'; | |
import ReactDOM from 'react-dom'; | |
const rowStyle = { | |
display: 'flex' | |
} | |
const squareStyle = { | |
'width': '60px', | |
'height': '60px', |
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
import React, { Suspense, useContext } from 'react'; | |
import { | |
BrowserRouter as Router, | |
Switch, | |
Route, | |
} from 'react-router-dom'; | |
import { routes } from './routes'; | |
import Loading from './RouteLoading.component'; | |
import Guarded from './guards/Guard.component'; | |
import AppContext from '../App.context'; |
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 write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
const MINUTE = 60 | |
const HOUR = MINUTE * 60 | |
const DAY = HOUR * 24 | |
const WEEK = DAY * 7 | |
function solution(time) { | |
const result = calculate(time) |
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 getWays(amount, coins) { | |
// Write your code here | |
const combinations = Array(amount+1).fill(0); | |
combinations[0] = 1 | |
for(const coin of coins) { | |
for(let i = 1; i < combinations.length; i++) { | |
if(i >= coin) { | |
combinations[i] += combinations[i - coin]; | |
} |
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
import { parse, addDays } from "date-fns"; | |
const currentTimeIsBetween = (startTime, endTime) => { | |
const currentDate = new Date(); | |
const startTimeDate = parse(startTime, "hh:mm aa", currentDate); | |
const endTimeDate = parse(endTime, "hh:mm aa", currentDate); | |
const start = startTimeDate.getTime(); | |
let end = endTimeDate.getTime(); | |
const current = currentDate.getTime(); |
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
import React from 'react'; | |
import { Form, Formik } from 'formik'; | |
import * as Yup from 'yup'; | |
import { Button } from '../../../components/buttons'; | |
import { InputField, SelectField } from '../../../components/Input/input'; | |
export function Form() { | |
return ( |
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 getUsersByChunkSize = async function * (chunkSize = 10) { | |
const limit = chunkSize; | |
let page = 1; | |
const total = await User.countDocuments({}); | |
for(let startAt = 0; startAt < total; startAt += limit) { | |
const users = await User.find({}).skip(startAt).limit(limit); |
NewerOlder