You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {'basic' | 'intermediate' | 'advanced' | 'extreme'} level - the level of the challenge.
61
+
* @param {string} challengeName - the name of the challenge.
62
+
* @returns void
63
+
*/
64
+
setPassed(level,challengeName){
65
+
constchallenges=this.state[level];
66
+
for(constchallengeofchallenges){
67
+
if(challenge.name===challengeName){
68
+
challenge.passed=true;
69
+
break;
70
+
}
71
+
}
72
+
73
+
this._save(this.state);
74
+
}
75
+
76
+
/**
77
+
* Merge the new state to the current state. this function will compare the new state with the current state and finally overwrite the current state based on the new state:
78
+
* - If the old key in the current state is not in the new state, the old key will be removed from the current state.
79
+
* - If the new key in the new state is not in the current state, the new key will be added to the current state.
80
+
* @param {object} newState
81
+
*/
82
+
_checkAndMerge(newState,oldState){
83
+
if(!newState&&!oldState){
84
+
thrownewError('one of the new state and the old state is required.');
85
+
}
86
+
87
+
if(!newState){
88
+
returnoldState;
89
+
}
90
+
// TODO: compare the new state with the old state and merge the new state to the old state.
0 commit comments