Skip to content

Commit c711d0b

Browse files
committed
practice to solve codewars problem
1 parent dd9cef7 commit c711d0b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

javascript/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,3 +1047,24 @@ let numerator = 1, denominator = 2;
10471047
// "0.5"
10481048
// console.log(fractionToDecimal(numerator,denominator));
10491049

1050+
function partlist(arr) {
1051+
// divide a list (an array) of at least two elements into two non-empty parts.
1052+
// Elements of a pair must be in the same order as in the original array.
1053+
let result = [];
1054+
// 切成兩個元素
1055+
// front多一個字,end則少一個字
1056+
let front = arr[0];
1057+
let original = arr.join(" ");
1058+
// console.log(original)
1059+
let inside = [];
1060+
for(let i = 0;i < arr.length;++i) {
1061+
1062+
// inside[i] = original[i];
1063+
// result.push(inside)
1064+
}
1065+
console.log(result)
1066+
}
1067+
let arr = ["I", "wish", "I", "hadn't", "come"];
1068+
// let expect = [["I", "wish I hadn't come"], ["I wish", "I hadn't come"], ["I wish I", "hadn't come"], ["I wish I hadn't", "come"]]
1069+
// console.log(assert.deepEqual(partlist(arr),expect));
1070+
console.log(partlist(arr));

0 commit comments

Comments
 (0)