[Clip 1]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function christmasDecoration(input) {
let budget = +input.shift();
let nameSubject = "";
let money = 0;
while (input != "Stop") {
nameSubject = input.shift();
for (let i = 0; i < nameSubject.length; i++) {
money += (nameSubject.charCodeAt(i));
}
if (money <= budget) {
console.log("Item successfully purchased!");
if (money <= budget && input == "Stop") {
console.log(`Money left: ${(budget - money)}`);
}
}
else {
console.log("Not enough money!");
break;
}
}
}
[Clip 2]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function christmasDecoration(input) {
let budget = +input.shift();
let nameSubject = input.shift();
let money = 0;
while (nameSubject !== "Stop") {
for (let i = 0; i < nameSubject.length; i++) {
money += (nameSubject.charCodeAt(i));
}
if (money > budget) {
console.log("Not enough money!");
break
}
console.log("Item successfully purchased!");
nameSubject = input.shift();
}
if (nameSubject === "Stop") {
console.log(`Money left: ${(budget - money)}`);
}
}
5 differences: 16 lines, 12 inline differences in 11 changed lines
Added(5,1)
Deleted(0,8)
Changed(11)
Changed in changed(3)
Ignored
Generated on January 10, 2020, 12:34 PM by ExamDiff Pro 10.0.1.7.