Skip to content

Commit fcaf871

Browse files
committed
somplify str.slice() method in 3-git card-value.js file
1 parent e638e78 commit fcaf871

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
1010
function getCardValue(card) {
11-
let rank = card.slice(0, -1);
11+
let rank = card.slice(0, card.length - 1);
1212
if (rank === "A") {
1313
return 11;
1414
}
@@ -23,6 +23,10 @@ function getCardValue(card) {
2323
return "Invalid card rank";
2424
}
2525

26+
let car = "10♠";
27+
28+
let ran = car.slice(0, -1);
29+
console.log(ran);
2630
// The line below allows us to load the getCardValue function into tests in other files.
2731
// This will be useful in the "rewrite tests with jest" step.
2832
module.exports = getCardValue;

Sprint-3/3-stretch/find.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
function find(str, char) {
22
let index = 0;
3+
34
while (index < str.length) {
45
if (str[index] === char) {
56
return index;
67
}
78
index++;
89
}
9-
1010
return -1;
1111
}
12-
1312
// console.log(find("code your future", "u"));
1413
// console.log(find("code your future", "z"));
1514

0 commit comments

Comments
 (0)