diff --git a/courses/strings/intro.md b/courses/strings/intro.md
index 779e535..79992fb 100644
--- a/courses/strings/intro.md
+++ b/courses/strings/intro.md
@@ -15,7 +15,7 @@ order: 1
```js
const doubleQuote = "This is a string";
-const singleQuote = 'This is also a string';
+const singleQuote = "This is also a string";
```
السبب وراء رغبتك في استخدام نوع واحد من علامات الاقتباس على الآخر هو إذا كنت
@@ -61,7 +61,7 @@ const sampleStr = 'Adam said, "Yazan is learning JavaScript"'.;
| `\\` | backslash | شرطة معكوفة |
| `n\` | newline | سطر جديد |
| `t\` | tab | مسافه |
-| `r\` | carriage return | ? |
+| `r\` | carriage return | carriage return |
| `b\` | backspace | مسافة إلى الوراء |
| `f\` | form feed | تغذية النموذج |
@@ -83,8 +83,9 @@ World;
```
-قم بإنشاء متغير و إستخدم تسلسلات التخطي لطباعة النص التالي على وحدة التحكم
-
Ich Bin Yazan
-
am Yazan
-يجب أن تكون في أسطر مختلفة
+قم بإنشاء متغير و إستخدم تسلسلات التخطي لطباعة النص التالي على وحدة التحكم:
+
+Hello
+World
+
diff --git a/courses/variables/console.md b/courses/variables/console.md
index 815c68b..d1fe380 100644
--- a/courses/variables/console.md
+++ b/courses/variables/console.md
@@ -26,7 +26,7 @@ console.log(myName);
1. قم بطباعة أي شيء على الشاشة واضغط تشغيل لمشاهده النتيجه
-2. اضغط على اختبار
+2. اضغط على اختبار لإرسال النتيجة
يمكنك التعرف على المزيد عن الكائن `console` في مستندات
diff --git a/courses/variables/uninitialized-variables.md b/courses/variables/uninitialized-variables.md
index c2b9a06..4512167 100644
--- a/courses/variables/uninitialized-variables.md
+++ b/courses/variables/uninitialized-variables.md
@@ -31,5 +31,5 @@ console.log(c); // "undefined String!"
-قم بتعريف أي متغير ثم غير قيمته إلى كلمه عربي
.
+قم بتعريف متغير غير المهيء ثم غير قيمته إلى كلمه عربي
.
diff --git a/testcases/EXAM_TEST_TEMPLATE.js b/testcases/EXAM_TEST_TEMPLATE.js
index 123c2e9..cb701b0 100644
--- a/testcases/EXAM_TEST_TEMPLATE.js
+++ b/testcases/EXAM_TEST_TEMPLATE.js
@@ -1,8 +1,3 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
try {
const capturedOutput = [];
diff --git a/testcases/arrays/intro.js b/testcases/arrays/intro.js
index c6baa46..d109827 100644
--- a/testcases/arrays/intro.js
+++ b/testcases/arrays/intro.js
@@ -1,9 +1,8 @@
const regex = /(let|const|var)\s*\w*\s*=\s*\[(("|`|')\w*\3(,|)(\s*|)(,|)(\s*|))*\]/g;
+
if (regex.test(code)) {
isPass = true;
- msg = 'Good job!';
}
else {
- isPass = false;
msg = "تحقق من الشروط المطلوبة"
}
\ No newline at end of file
diff --git a/testcases/arrays/manipulate-arrays.js b/testcases/arrays/manipulate-arrays.js
index fd97717..883ba39 100644
--- a/testcases/arrays/manipulate-arrays.js
+++ b/testcases/arrays/manipulate-arrays.js
@@ -22,12 +22,12 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
code += "\nconsole.log(myArray);";
const out = handleCodeRun(code);
+
if (out === '["b","c","d","Ali",35]') {
isPass = true;
- msg = "Pass!";
} else {
- isPass = false;
- msg = "Fail!";
+ msg = "Fail!";
}
\ No newline at end of file
diff --git a/testcases/arrays/multidimensional-index.js b/testcases/arrays/multidimensional-index.js
index 8002189..bda255f 100644
--- a/testcases/arrays/multidimensional-index.js
+++ b/testcases/arrays/multidimensional-index.js
@@ -1,8 +1,7 @@
-const regex = /console.log\(\s*arr\[3\]\[1\]\s*\)/
+const regex = /console.log\(\s*arr\[3\]\[1\]\s*\)/
+
if (regex.test(code)) {
isPass = true
- msg = "مبروك، الجواب صحيح"
} else {
- isPass = false
msg = "الجواب خاطئ"
}
\ No newline at end of file
diff --git a/testcases/comments.js b/testcases/comments.js
index 946ea3d..7b5b926 100644
--- a/testcases/comments.js
+++ b/testcases/comments.js
@@ -1,8 +1,7 @@
const regex = /(? ___; i -= ___) {
// console.log(i);
// }
-if (code.include('for (let i = 10; i > 0; i -= 2) {')) { // TODO: convert to regex
+if (code.includes('for (let i = 10; i > 0; i -= 2) {')) { // TODO: convert to regex
isPass = true;
} else {
- isPass = false;
- feedback = 'The code is not a for loop that counts backwards.';
+ msg = 'تحقق الرجاء من استخدام الحلقة الصحيحة للتكرار.';
}
\ No newline at end of file
diff --git a/testcases/loops/iterate-using-for-loops.js b/testcases/loops/iterate-using-for-loops.js
index e8f716e..5a0f018 100644
--- a/testcases/loops/iterate-using-for-loops.js
+++ b/testcases/loops/iterate-using-for-loops.js
@@ -21,16 +21,15 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
if (code.includes("for")) {
- let output = handleCodeRun(code+"\nconsole.log(oddNumbers);")
+ let output = handleCodeRun(code + "\nconsole.log(oddNumbers);")
output = output[output.length - 1];
if (output == JSON.stringify([1, 3, 5, 7, 9])) {
isPass = true;
} else {
- isPass = false;
msg = "تأكد من النتائج";
}
} else {
- isPass = false;
msg = "الرجاء التأكد من استخدام الحلقة الصحيحة للتكرار.";
}
\ No newline at end of file
diff --git a/testcases/loops/iterate-using-while-loops.js b/testcases/loops/iterate-using-while-loops.js
index 3c828ac..b36bf86 100644
--- a/testcases/loops/iterate-using-while-loops.js
+++ b/testcases/loops/iterate-using-while-loops.js
@@ -22,16 +22,15 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
if (code.includes("while")) {
- const output = handleCodeRun(code);
+ const output = handleCodeRun(code);
console.log(output);
- if (JSON.stringify(output) === JSON.stringify([ '1', '2', '3', '4', '5' ])) {
+ if (JSON.stringify(output) === JSON.stringify(['1', '2', '3', '4', '5'])) {
isPass = true;
} else {
- isPass = false;
msg = "الرجاء التأكد من استخدام الحلقة الصحيحة للتكرار.";
}
} else {
- isPass = false;
msg = "الرجاء التأكد من استخدام الحلقة الصحيحة للتكرار.";
}
\ No newline at end of file
diff --git a/testcases/numbers/decimals.js b/testcases/numbers/decimals.js
index a59a42f..c83cb9a 100644
--- a/testcases/numbers/decimals.js
+++ b/testcases/numbers/decimals.js
@@ -1,40 +1,40 @@
function handleCodeRun(code) {
- try {
- const capturedOutput = [];
- const originalConsoleLog = console.log;
- console.log = (...args) => {
- capturedOutput.push(
- args.map((arg) => {
- if (typeof arg === "object" && arg !== null) {
- return JSON.stringify(arg);
- }
- return arg.toString();
- }).join(" "),
- );
- originalConsoleLog(...args);
- };
- if (code) {
- eval(code);
- }
- console.log = originalConsoleLog;
- return capturedOutput.join("\n");
- } catch (error) {
- return `${error}`;
+ try {
+ const capturedOutput = [];
+ const originalConsoleLog = console.log;
+ console.log = (...args) => {
+ capturedOutput.push(
+ args.map((arg) => {
+ if (typeof arg === "object" && arg !== null) {
+ return JSON.stringify(arg);
+ }
+ return arg.toString();
+ }).join(" "),
+ );
+ originalConsoleLog(...args);
+ };
+ if (code) {
+ eval(code);
}
+ console.log = originalConsoleLog;
+ return capturedOutput.join("\n");
+ } catch (error) {
+ return `${error}`;
}
+}
+
const regexMyDec = /\bmyDecimal\b = 3\.14/;
const product_pattern = /product = myDecimal \* 4/;
const print_pattern = /console\.log\(product\)/;
+
if (regexMyDec.test(code) && product_pattern.test(code) && print_pattern.test(code)) {
- const output = handleCodeRun(code);
- if (output === "12.56") {
- isPass = true;
- msg = "اجابة صحيحة";
- } else {
- isPass = false;
- msg = "قيمة myDecimal غير صحيحة";
- }
+ const output = handleCodeRun(code);
+ if (output === "12.56") {
+ isPass = true;
+ msg = "اجابة صحيحة";
+ } else {
+ msg = "قيمة myDecimal غير صحيحة";
+ }
} else {
- isPass = false;
- msg = "لم يتم إنشاء متغير myDecimal وحساب قيمة المتغير product وطباعة قيمة المتغير product";
+ msg = "لم يتم إنشاء متغير myDecimal وحساب قيمة المتغير product وطباعة قيمة المتغير product";
}
\ No newline at end of file
diff --git a/testcases/numbers/intro.js b/testcases/numbers/intro.js
index 902a93a..e905b99 100644
--- a/testcases/numbers/intro.js
+++ b/testcases/numbers/intro.js
@@ -22,9 +22,10 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
const output = handleCodeRun(code);
+
if (output != "50") {
- isPass = false;
msg = "هناك خطاء في الكود";
} else {
const regexWidth = /(let|const|var)(\s*)width(\s*)?=(\s*)?10(;)?/g
@@ -33,10 +34,8 @@ if (output != "50") {
const regex = [regexWidth, regexLength, regexArea]
const results = regex.map((reg) => reg.test(code))
if (results.includes(false)) {
- isPass = false;
msg = "هناك خطاء في الكود";
} else {
isPass = true;
- msg = "احسنت";
}
}
\ No newline at end of file
diff --git a/testcases/objects/accessing-nested-objects.js b/testcases/objects/accessing-nested-objects.js
index 7991589..c35075d 100644
--- a/testcases/objects/accessing-nested-objects.js
+++ b/testcases/objects/accessing-nested-objects.js
@@ -1,8 +1,3 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
try {
const capturedOutput = [];
@@ -27,15 +22,14 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
const output = handleCodeRun(code)
if (output == "1500") {
if (code.includes("console.log(1500)" || 'console.log("1500")' || "console.log('1500')")) {
- isPass = false;
msg = "لا تحتال علينا, حاول مرة أخرى";
} else {
isPass = true;
}
} else {
- isPass = false;
- msg = "حاول مرة أخرى";
+ msg = "حاول مرة أخرى";
}
\ No newline at end of file
diff --git a/testcases/objects/accessing-object-properties-with-variables.js b/testcases/objects/accessing-object-properties-with-variables.js
index 995ea4d..c1a8986 100644
--- a/testcases/objects/accessing-object-properties-with-variables.js
+++ b/testcases/objects/accessing-object-properties-with-variables.js
@@ -1,8 +1,8 @@
// the code must contain console.log(fighter[Country])
const codeRegex = /console.log\(fighter\[Country\]\)/;
+
if (codeRegex.test(code)) {
isPass = true;
} else {
- isPass = false;
- msg = "مالك ما عارف تحل؟؟؟؟"
+ msg = "تاكد من الشروط";
}
\ No newline at end of file
diff --git a/testcases/objects/accessing-object-properties.js b/testcases/objects/accessing-object-properties.js
index c96d22e..90fbcfe 100644
--- a/testcases/objects/accessing-object-properties.js
+++ b/testcases/objects/accessing-object-properties.js
@@ -1,8 +1,3 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
try {
const capturedOutput = [];
@@ -27,11 +22,11 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
const output = handleCodeRun(code);
// TODO: make the quiz uncheatable by checking the the code logic
if (output == "19812") {
isPass = true;
} else {
- isPass = false;
msg = "الناتج خطاء"
}
\ No newline at end of file
diff --git a/testcases/objects/delete-properties-from-object.js b/testcases/objects/delete-properties-from-object.js
index 3918432..a4ffc55 100644
--- a/testcases/objects/delete-properties-from-object.js
+++ b/testcases/objects/delete-properties-from-object.js
@@ -1,7 +1,5 @@
-// if code contain `delete fighter.operator` then isPass = true
if (code.includes("delete") && code.includes("operator") && code.includes("fighter")) {
isPass = true;
} else {
- isPass = false;
msg = "الله يبارك فيك ركز شوية وحاول مره ثانية"
}
\ No newline at end of file
diff --git a/testcases/objects/intro.js b/testcases/objects/intro.js
index 8285ef8..c73298d 100644
--- a/testcases/objects/intro.js
+++ b/testcases/objects/intro.js
@@ -22,6 +22,6 @@ function handleCodeRun(code) {
return `${error}`;
}
}
-code += "\ntry { isPass = true; if (car.manufacturer == undefined || car.model == undefined) isPass = false; } catch (e) { isPass = false; msg = e.message; }"
+code += "\ntry { isPass = true; if (car.manufacturer == undefined || car.model == undefined) isPass = false; } catch (e) { isPass = false; msg = e.message; }"
eval(code)
\ No newline at end of file
diff --git a/testcases/objects/manipulating-complex-objects.js b/testcases/objects/manipulating-complex-objects.js
index 9469fab..0e60cbc 100644
--- a/testcases/objects/manipulating-complex-objects.js
+++ b/testcases/objects/manipulating-complex-objects.js
@@ -1,8 +1,3 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
try {
const capturedOutput = [];
@@ -27,17 +22,15 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
if (!code.includes('october-73')) {
- isPass = false;
msg = "هل قمت بتعديل القيمة الصحيحة؟";
} else {
const output = handleCodeRun(code + "\nconsole.log(fighter.wars[0]);")
console.log(output);
if (output.includes("october-73")) {
isPass = true;
- msg = "احسنت";
} else {
- isPass = false;
msg = "هل قمت بتعديل القيمة الصحيحة؟";
}
diff --git a/testcases/objects/testing-objects-for-properties.js b/testcases/objects/testing-objects-for-properties.js
index 98b1ccf..ff96571 100644
--- a/testcases/objects/testing-objects-for-properties.js
+++ b/testcases/objects/testing-objects-for-properties.js
@@ -1,8 +1,7 @@
-// the code must contain this line console.log(fighter.hasOwnProperty("speed"))
const regex = /console.log\((\w+)\.hasOwnProperty\("(speed)"\)\)/;
+
if (regex.test(code)) {
isPass = true;
} else {
- isPass = false;
msg = "قم بالتأكد من استخدام الدالة hasOwnProperty() للتأكد من وجود الخاصية في الكائن المعطى."
}
\ No newline at end of file
diff --git a/testcases/objects/updating-object-properties.js b/testcases/objects/updating-object-properties.js
index 6998206..4be4d98 100644
--- a/testcases/objects/updating-object-properties.js
+++ b/testcases/objects/updating-object-properties.js
@@ -1,8 +1,3 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
try {
const capturedOutput = [];
@@ -34,6 +29,5 @@ const expectedOutput = "2450";
if (output.includes(expectedOutput)) {
isPass = true;
} else {
- isPass = false;
msg = "الله يبارك فيك ركز شوية وحاول مره ثانية"
}
diff --git a/testcases/strings/bracket-examples.js b/testcases/strings/bracket-examples.js
index 236be28..94318df 100644
--- a/testcases/strings/bracket-examples.js
+++ b/testcases/strings/bracket-examples.js
@@ -1,38 +1,37 @@
function handleCodeRun(code) {
- try {
- const capturedOutput = [];
- const originalConsoleLog = console.log;
- console.log = (...args) => {
- capturedOutput.push(
- args.map((arg) => {
- if (typeof arg === "object" && arg !== null) {
- return JSON.stringify(arg);
- }
- return arg.toString();
- }).join(" "),
- );
- originalConsoleLog(...args);
- };
- if (code) {
- eval(code);
- }
- console.log = originalConsoleLog;
- return capturedOutput.join("\n");
- } catch (error) {
- return `${error}`;
+ try {
+ const capturedOutput = [];
+ const originalConsoleLog = console.log;
+ console.log = (...args) => {
+ capturedOutput.push(
+ args.map((arg) => {
+ if (typeof arg === "object" && arg !== null) {
+ return JSON.stringify(arg);
+ }
+ return arg.toString();
+ }).join(" "),
+ );
+ originalConsoleLog(...args);
+ };
+ if (code) {
+ eval(code);
}
+ console.log = originalConsoleLog;
+ return capturedOutput.join("\n");
+ } catch (error) {
+ return `${error}`;
}
+}
+
const regex = /console.log\(\s*("|'|`)u("|'|`)\s*\)/;
+
if (regex.test(code)) {
- isPass = false;
- msg = "أنت تحاول الغش 😠";
+ msg = "أنت تحاول الغش 😠";
} else {
- const output = handleCodeRun(code);
- if (output !== "s") {
- isPass = false;
- msg = "الحرف المطلوب طباعته هو حرف s";
- } else {
- isPass = true;
- msg = "اجابة صحيحة";
- }
+ const output = handleCodeRun(code);
+ if (output !== "s") {
+ msg = "الحرف المطلوب طباعته هو حرف s";
+ } else {
+ isPass = true;
+ }
}
diff --git a/testcases/strings/concatenating-strings.js b/testcases/strings/concatenating-strings.js
index cc0f597..2d43365 100644
--- a/testcases/strings/concatenating-strings.js
+++ b/testcases/strings/concatenating-strings.js
@@ -1,10 +1,9 @@
const regex1 = /(var|let)\s*x\s*=\s*"JavaScript\s*"(;|)/;
const regex2 = /(const|var|let)\s*y\s*=\s*"Is fun"(;|)/;
const regex3 = /x\s*\+=+\s*y(;|)/;
+
if (regex1.test(code) && regex2.test(code) && regex3.test(code)) {
isPass = true;
- msg = "قمت بحل السؤال بشكل صحيح";
} else {
- isPass = false;
msg = "لم تقم بحل السؤال بشكل صحيح";
}
\ No newline at end of file
diff --git a/testcases/strings/intro.js b/testcases/strings/intro.js
index 69f4f5d..c907790 100644
--- a/testcases/strings/intro.js
+++ b/testcases/strings/intro.js
@@ -1,41 +1,38 @@
-/**
- * Executes the provided code and captures the output of console.log.
- * @param {string} code - The code to be executed.
- * @returns {string} - The captured output of console.log.
- */
function handleCodeRun(code) {
- try {
- const capturedOutput = [];
- const originalConsoleLog = console.log;
- console.log = (...args) => {
- capturedOutput.push(
- args.map((arg) => {
- if (typeof arg === "object" && arg !== null) {
- return JSON.stringify(arg);
- }
- return arg.toString();
- }).join(" "),
- );
- originalConsoleLog(...args);
- };
- if (code) {
- eval(code);
- }
- console.log = originalConsoleLog;
- return capturedOutput
- } catch (error) {
- return `${error}`;
- }
+ try {
+ const capturedOutput = [];
+ const originalConsoleLog = console.log;
+ console.log = (...args) => {
+ capturedOutput.push(
+ args.map((arg) => {
+ if (typeof arg === "object" && arg !== null) {
+ return JSON.stringify(arg);
+ }
+ return arg.toString();
+ }).join(" "),
+ );
+ originalConsoleLog(...args);
+ };
+ if (code) {
+ eval(code);
+ }
+ console.log = originalConsoleLog;
+ return capturedOutput
+ } catch (error) {
+ return `${error}`;
+ }
}
const output = handleCodeRun(code);
const regex = /(let|const|var)\s+\w+\s*=/;
+
if (regex.test(code)) {
- if (output == "Ich Bin Yazan\nI am Yazan") {
+ if (!code.includes("\\n")) {
+ msg = "يجب أن تكون في أسطر مختلفة ";
+ } else if (output == "Hello\nWorld") {
isPass = true;
} else {
- isPass = false;
- msg = "The output is not correct";
+ msg = "الإخراج غير صحيح";
}
}
diff --git a/testcases/strings/understand-immutability.js b/testcases/strings/understand-immutability.js
index 65c2292..a9b234e 100644
--- a/testcases/strings/understand-immutability.js
+++ b/testcases/strings/understand-immutability.js
@@ -1,9 +1,6 @@
-// code if the code contains animal[0] = "ف";
const regex = /animal\s*=\s*["']فيل["']/;
if (regex.test(code)) {
isPass = true;
- msg = "احسنت";
} else {
- isPass = false;
msg = "هل قمت بتغيير الحرف الأول من كلمة قيل إلى ف؟";
}
\ No newline at end of file
diff --git a/testcases/strings/use-brackets.js b/testcases/strings/use-brackets.js
index 245e0c1..84581e3 100644
--- a/testcases/strings/use-brackets.js
+++ b/testcases/strings/use-brackets.js
@@ -22,17 +22,16 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
const regex = /country\[2\]/;
+
if (regex.test(code)) {
const output = handleCodeRun(code);
if (output.includes("r")) {
isPass = true;
- msg = "احسنت";
} else {
- isPass = false;
- msg = "هل قمت بطباعة الحرف r من كلمة Syria باستخدام الأقواس؟";
+ msg = "هل قمت بطباعة الحرف من الكلمة باستخدام الأقواس؟";
}
} else {
- isPass = false;
- msg = "هل قمت بطباعة الحرف r من كلمة Syria باستخدام الأقواس؟";
+ msg = "هل قمت بطباعة الحرف من الكلمة باستخدام الأقواس؟";
}
\ No newline at end of file
diff --git a/testcases/variables/case-sensitivity-in-variables.js b/testcases/variables/case-sensitivity-in-variables.js
index e9e6458..9a00179 100644
--- a/testcases/variables/case-sensitivity-in-variables.js
+++ b/testcases/variables/case-sensitivity-in-variables.js
@@ -22,23 +22,20 @@ function handleCodeRun(code) {
return `${error}`;
}
}
+
try {
const output = handleCodeRun(code);
if (output !== "5") {
- isPass = false;
msg = "القيمة المطبوعة غير صحيحة";
}
} catch (error) {
- isPass = false;
msg = error;
}
-// make regex check if student console.log() the variable not string
const regex = /console\.log\((?!("|'|`|5))(.+?)\)/
+
if (!regex.test(code)) {
- isPass = false;
- msg = "لم تتم طباعة قيمة المتغير أي قيمة أو أنك تحاول الغش";
+ msg = "لم تتم طباعة قيمة المتغير";
} else {
- isPass = true;
- msg = "اجابة صحيحة";
+ isPass = true;
}
diff --git a/testcases/variables/console.js b/testcases/variables/console.js
index fdcab77..c9e541a 100644
--- a/testcases/variables/console.js
+++ b/testcases/variables/console.js
@@ -1,9 +1,7 @@
-// check if there are any console.log() statements
const regex = /console\.log\(.*\)/;
+
if (!regex.test(code)) {
- isPass = false;
msg = "لم يتم استخدام الأمر console.log() لطباعة النص المطلوب";
} else {
isPass = true;
- msg = "اجابة صحيحة";
}
\ No newline at end of file
diff --git a/testcases/variables/intro.js b/testcases/variables/intro.js
index fbb21e9..772d7c5 100644
--- a/testcases/variables/intro.js
+++ b/testcases/variables/intro.js
@@ -1,6 +1,6 @@
const regex = /var\s+(\w+)\s*(?:=\s*[^;]+)?\s*;\s*/;
+
if (!regex.test(code)) {
- isPass = false;
msg = "لم يتم إنشاء متغير وتعيين قيمة له";
} else {
const matches = code.match(regex);
@@ -9,9 +9,7 @@ if (!regex.test(code)) {
if (assignRegex.test(code)) {
isPass = true;
- msg = "اجابة صحيحة";
} else {
- isPass = false;
msg = "لم يتم إنشاء متغير وتعيين قيمة له";
}
}
\ No newline at end of file
diff --git a/testcases/variables/uninitialized-variables.js b/testcases/variables/uninitialized-variables.js
index b7ad3bb..57121f5 100644
--- a/testcases/variables/uninitialized-variables.js
+++ b/testcases/variables/uninitialized-variables.js
@@ -1,23 +1,18 @@
-// check if there are uninitialized variables using regex
let regex = /(let|var)\s+\w+\s*/g;
+
if (!regex.test(code)) {
- isPass = false;
msg = "لم تقم بتعريف متغير غير المهيأة"
} else {
- // get the variables name
regex = /(let|var)\s+(\w+)\s*/g;
const variables = code.match(regex).map(match => match.split(' ')[1]);
if (variables.length != 1) {
- isPass = false;
- msg = "ما حد طلب منك تعريف أكثر من متغير غير مهيأة "
+ msg = "ما حد طلب منك تعريف أكثر من متغير غير مهيأة"
} else {
regex = /\w+(\s+|)=(\s+|)("|'|`)عربي("|'|`)/
if (!regex.test(code)) {
- isPass = false;
msg = "لم تقم بتغير قيمة المتغير غير المهيأة"
} else {
isPass = true;
- msg = "احسنت"
}
}