Skip to content

Instantly share code, notes, and snippets.

View emayom's full-sized avatar
👋

emayom emayom

👋
View GitHub Profile
🌞 Morning 109 commits █████▋░░░░░░░░░░░░░░░ 27.3%
🌆 Daytime 55 commits ██▉░░░░░░░░░░░░░░░░░░ 13.8%
🌃 Evening 87 commits ████▌░░░░░░░░░░░░░░░░ 21.8%
🌙 Night 148 commits ███████▊░░░░░░░░░░░░░ 37.1%
@emayom
emayom / router.js
Created November 3, 2023 06:26
[F-Lab] History API를 활용하여 SPA Router 구현
export default (function(){
let instance = null;
/**
* Create a new Router.
* @class
* @param {HTMLElement} root
* @param {object} [options]
*/
function Router(root, options){
if(!(root instanceof HTMLElement)){
@emayom
emayom / async.js
Last active October 16, 2021 15:19
sync vs async
//동기 방식으로 작동하는 코드
function loop() {
//for문을 실행하기 전
const start = Date.now();
//i가 9999999가 될 때 까지 ++
for (let i = 0; i <= 9999999; i++) {}
const end = Date.now();
@emayom
emayom / grade_01.js
Last active August 26, 2021 06:25
[프로그래머스] 위클리챌린지 2주차
function solution(sample) {
let scores = [];
let grades = "";
const S_LENGTH = sample.length;
function calc(index, score){
const MAX = Math.max(...score);
const MIN = Math.min(...score);
const SELF = score[index];
@emayom
emayom / weekly_field_01.js
Last active August 25, 2021 02:35
[프로그래머스] 위클리챌린지 직업군 추천하기
function solution(table, languages, preference) {
const FIELD = ["SI", "CONTENTS", "HARDWARE", "PORTAL", "GAME"];
const separate = [];
const count = [];
let answer = [];
for(let i of table){
let temp = i.split(' ');
separate.push(temp.slice(1));
@emayom
emayom / brute_force_search_01.js
Last active August 24, 2021 05:01
[프로그래머스] 모의고사
// solution 1
function solution(answers) {
const submit = ["12345", "21232425", "3311224455"];
function cnt(submit) {
const A_LENGTH = answers.length;
const S_LENGTH = submit.length;
if(A_LENGTH > S_LENGTH){
@emayom
emayom / arry_from.html
Last active August 24, 2021 00:49
[ES6] Array.from() NodeList -> object Array
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>apple</li>
<li>orange</li>
@emayom
emayom / next_01.js
Last active August 23, 2021 05:55
[프로그래머스] 다음 큰 숫자
//solution 01
function solution(n) {
function cnt(number) {
return number.toString(2)
.match(/1/g)
.length;
}
const n_cnt = cnt(n);
let start = n;
@emayom
emayom / stack_solution_01.js
Created August 22, 2021 07:47
[프로그래머스] 기능개발
function solution(progresses, speeds) {
let answer = progresses.map((el, index) => Math.ceil((100 - el) / speeds[index]));
const LENGTH = answer.length;
let temp = [];
let cnt = 1;
let max = answer[0];
for(let i = 1; i < LENGTH; i++){
if(max >= answer[i]){
@emayom
emayom / max_min_01.js
Created August 22, 2021 07:03
[프로그래머스] 최댓값과 최솟값
function solution(s) {
s = s.split(' ').sort((a,b) => a-b);
let answer = [(s[0]), s[s.length-1]];
return answer.join(' ');
}