I am new here and wish you everything goes awesome!
This question is about t
I wanna get the result like
a is ok
b is ok
c is changed
d is fail
e is ok
a is ok
b is ok
c is changed
d is fail
using these javascript
var i = 0;
function arrayList() {
var list = ["a", "b", "c", "d", "e"];
var result = list[i];
i = i + 1;
if (i === 5) {
i = 0;
}
return result;
}
function switchCD(arrayListValue) {
switch (arrayListValue) {
case "c":
case "d": {
arrayListValue = arrayListValue + " is changed";
console.log(arrayListValue);
var switchCDValue = arrayList();
return switchCDValue;
}
}
}
function failOk(switchCDValue) {
if (switchCDValue === "c" || switchCDValue === "d") {
switchCDValue = switchCDValue + " is fail";
console.log(switchCDValue);
} else {
switchCDValue = switchCDValue + " is ok";
console.log(switchCDValue);
}
return switchCDValue;
}
function loop() {
for (var i = 0; i < 7; i++) {
var test1 = arrayList();
var test2 = switchCD(test1);
failOk(test2);
}
}
loop();but I don't know where it go wrong here.
Please help me to figure it out.
Aucun commentaire:
Enregistrer un commentaire