Research portable Memory game | Исследовать портируемую игру Память
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

35 lignes
621B

  1. function memory_generateConstPlayfield(
  2. n
  3. ) {
  4. var idGroups = {};
  5. var id = 0;
  6. for (let gid = 0; gid < n; ++gid) {
  7. idGroups[id] = gid;
  8. id += 1;
  9. idGroups[id] = gid;
  10. id += 1;
  11. }
  12. return idGroups;
  13. }
  14. function test_memory_generateConstPlayfield() {
  15. let idGroups = memory_generateConstPlayfield(2)
  16. if (
  17. Object.keys(idGroups).length == 4 &&
  18. idGroups[0] == 0 &&
  19. idGroups[1] == 0 &&
  20. idGroups[2] == 1 &&
  21. idGroups[3] == 1
  22. ) {
  23. return "OK: memory_generateConstPlayfield"
  24. }
  25. return "ERR: memory_generateConstPlayfield"
  26. }
  27. console.log(test_memory_generateConstPlayfield())