-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
151 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "تحقق من الشروط المطلوبة" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "الجواب خاطئ" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
const regex = /(?<!\\)\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/|(?<!\\)\/\/[^\n]*(?:\n|$)/ | ||
|
||
if (regex.test(code)) { | ||
isPass = true, | ||
msg = "" | ||
isPass = true | ||
} else { | ||
isPass = false; | ||
msg = "لا يوجد تعليقات في الكود" | ||
msg = "لا يوجد تعليقات في الكود" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
isPass = true; | ||
msg = "Passes all the test cases"; | ||
isPass = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
isPass = true; | ||
msg = ""; | ||
isPass = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
// for (let i = ___; i > ___; 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 = 'تحقق الرجاء من استخدام الحلقة الصحيحة للتكرار.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
testcases/objects/accessing-object-properties-with-variables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "تاكد من الشروط"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "الله يبارك فيك ركز شوية وحاول مره ثانية" | ||
} |
Oops, something went wrong.