-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbit.js
51 lines (47 loc) · 1.32 KB
/
rabbit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// function solution(common) {
// var answer = 0;
// const length = common.length - 1;
// if (common[2] / common[1] === common[0]) {
// const diff = common[2] / common[1];
// console.log(diff);
// return common[length] * diff;
// } else {
// const diff = common[1] - common[0];
// return common[length] + diff;
// }
// }
// function solution2(common) {
// var answer = 0;
// const length = common.length - 1;
// if (common[0] + common[1] === common[2]) {
// const diff = common[1] - common[0];
// return common[length] + diff;
// } else {
// const diff = common[2] / common[1];
// console.log(diff);
// return common[length] * diff;
// }
// }
// let common = [1, 2, 3, 4, 5];
// console.log(common.pop());
// console.log(common);
// for (i = 0; i < array.length; i++) {
// const repeat = String(array[i]);
// for (j = 0; j < repeat.length; j++) {
// let first = repeat.slice(0, 1);
// let others = repeat.slice(1, -1);
// console.log("first: ", first);
// console.log("repeat: ", repeat);
// console.log("others: ", others);
// if (first === "7") {
// answer += 1;
// first = others;
// }
// }
// }
console.log(
Array.from(
{ length: 20 }, // 유사배열
() => Array(10).fill(0) // 각각의 배열에 적용할 함수
)
);