Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
-
-
-
- // L4: Function.
-
- function memory_generateConstPlayfield(
- n
- ) {
- var idGroups = {};
- var id = 0;
- for (let gid = 0; gid < n; ++gid) {
- idGroups[id] = gid;
- id += 1;
- idGroups[id] = gid;
- id += 1;
- }
- return idGroups;
- }
-
- // L20: Test.
-
- function test_memory_generateConstPlayfield() {
- let idGroups = memory_generateConstPlayfield(2)
- if (
- Object.keys(idGroups).length == 4 &&
- idGroups[0] == 0 &&
- idGroups[1] == 0 &&
- idGroups[2] == 1 &&
- idGroups[3] == 1
- ) {
- return "OK: memory_generateConstPlayfield"
- }
- return "ERR: memory_generateConstPlayfield"
- }
-
- // L36: Run.
-
- console.log(test_memory_generateConstPlayfield())
|