File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,14 @@ print(is_even(9)) # Output: False
1010# return number % 2 === 0;
1111# }
1212# console.log(isEven(6)); # Output: true
13- # console.log(isEven(9)); # Output: false
13+ # console.log(isEven(9)); # Output: false
14+
15+
16+ ##Explanation
17+
18+ In Python, the logic expressed as return number % 2 == 0, which evaluates to true or false.
19+ In JavaScript, the same idea is written as return number % 2 ===0, which evaluates to true or false.
20+ The main difference lies in the syntax Python uses def to define functions and print() to display results,
21+ while JavaScript uses the function keyword and console.log() to output results. When tested with the numbers
22+ 6 and 9, both versions correctly identify 6 as even and 9 as odd, demonstrating that although the syntax differs
23+ between the 2 languages, the underlying logic is exactly the same.
You can’t perform that action at this time.
0 commit comments