חידה אוהבים תשבצים/תשחצים? זה ממכר!

הספרן

מהמשתמשים המובילים!
מנוי פרימיום
כתיבה ספרותית
יוצרי ai

קבצים מצורפים

  • נקוד.jpg
    נקוד.jpg
    KB 13.5 · צפיות: 29

מנוי פרימיום

מהמשתמשים המובילים!
הנדסת תוכנה
D I G I T A L
יוצרי ai
@roni ravitz פתוח לקבלת קוד?
ההתאמה הבאה לפונקציה nextQuestion תאפשר מחיקת אותיות שהוקלדו בטעות:
JavaScript:
function nextQuestion(number) {
  const question = randomQuestions[number].question;
  document.querySelector(".question").innerText = question;

  //create inputs
  const inputsLength = randomQuestions[number].answer.length;
  for (let i = 1; i <= inputsLength; i++) {
    let input = document.createElement("input");
    document.querySelector(".answer").appendChild(input);
  }

  const answer = randomQuestions[number].answer;

  const inputs = document.querySelectorAll("input");
  const values = Array.from(inputs).map((input) => input.value);
  const inputsJoin = values.join("");

  //focus
  inputs[0].focus();
  inputs.forEach((e, index) => {
    e.addEventListener("keydown", (event) => {
      const previewsInput = e.previousSibling;
      if(event.key === 'Backspace' && previewsInput){
          previewsInput.focus();
          return;
      }
    });
      
    e.addEventListener("input", (event) => {
      const nextInput = e.nextElementSibling;
      // console.log(event);
      if (nextInput && event.data !== null) {
        nextInput.focus();
      }

      //correct answer
      const values = Array.from(inputs).map((input) => input.value);
      const inputsJoin = values.join("");
      if (inputsJoin === answer) {
        newQuestion();
      }
    });
  });

  //timer
  let timer = 10;
  document.querySelector(".timer").innerText = timer;
  const interval = setInterval(() => {
    timer--;
    document.querySelector(".timer").innerText = timer;
    if (timer < 0) {
      newQuestion();
    }
  }, 1000);

  function newQuestion() {
    clearInterval(interval);
    score = score + Number(document.querySelector(".timer").innerText);
    console.log(score);
    if (number === 9) {
      //the end
      document.querySelector("dialog").showModal();
      document.querySelector(".score").innerText = score;
    } else {
      document.querySelector(".answer").innerHTML = "";
      const nextNumber = number + 1;
      nextQuestion(nextNumber);
    }
  }
}
 

אולי מעניין אותך גם...

הפרק היומי

הפרק היומי! כל ערב פרק תהילים חדש. הצטרפו אלינו לקריאת תהילים משותפת!


תהילים פרק קמד

א לְדָוִד בָּרוּךְ יְהוָה צוּרִי הַמְלַמֵּד יָדַי לַקְרָב אֶצְבְּעוֹתַי לַמִּלְחָמָה:ב חַסְדִּי וּמְצוּדָתִי מִשְׂגַּבִּי וּמְפַלְטִי לִי מָגִנִּי וּבוֹ חָסִיתִי הָרוֹדֵד עַמִּי תַחְתָּי:ג יְהוָה מָה אָדָם וַתֵּדָעֵהוּ בֶּן אֱנוֹשׁ וַתְּחַשְּׁבֵהוּ:ד אָדָם לַהֶבֶל דָּמָה יָמָיו כְּצֵל עוֹבֵר:ה יְהוָה הַט שָׁמֶיךָ וְתֵרֵד גַּע בֶּהָרִים וְיֶעֱשָׁנוּ:ו בְּרוֹק בָּרָק וּתְפִיצֵם שְׁלַח חִצֶּיךָ וּתְהֻמֵּם:ז שְׁלַח יָדֶיךָ מִמָּרוֹם פְּצֵנִי וְהַצִּילֵנִי מִמַּיִם רַבִּים מִיַּד בְּנֵי נֵכָר:ח אֲשֶׁר פִּיהֶם דִּבֶּר שָׁוְא וִימִינָם יְמִין שָׁקֶר:ט אֱלֹהִים שִׁיר חָדָשׁ אָשִׁירָה לָּךְ בְּנֵבֶל עָשׂוֹר אֲזַמְּרָה לָּךְ:י הַנּוֹתֵן תְּשׁוּעָה לַמְּלָכִים הַפּוֹצֶה אֶת דָּוִד עַבְדּוֹ מֵחֶרֶב רָעָה:יא פְּצֵנִי וְהַצִּילֵנִי מִיַּד בְּנֵי נֵכָר אֲשֶׁר פִּיהֶם דִּבֶּר שָׁוְא וִימִינָם יְמִין שָׁקֶר:יב אֲשֶׁר בָּנֵינוּ כִּנְטִעִים מְגֻדָּלִים בִּנְעוּרֵיהֶם בְּנוֹתֵינוּ כְזָוִיֹּת מְחֻטָּבוֹת תַּבְנִית הֵיכָל:יג מְזָוֵינוּ מְלֵאִים מְפִיקִים מִזַּן אֶל זַן צֹאונֵנוּ מַאֲלִיפוֹת מְרֻבָּבוֹת בְּחוּצוֹתֵינוּ:יד אַלּוּפֵינוּ מְסֻבָּלִים אֵין פֶּרֶץ וְאֵין יוֹצֵאת וְאֵין צְוָחָה בִּרְחֹבֹתֵינוּ:טו אַשְׁרֵי הָעָם שֶׁכָּכָה לּוֹ אַשְׁרֵי הָעָם שֶׁיֲהוָה אֱלֹהָיו:
נקרא  20  פעמים

ספירת העומר

לוח מודעות

למעלה