Pseudocode → Real code
You already know how to think. Now let’s see the exact same logic in PHP and JavaScript. The logic didn’t change — only the syntax did.
Best after the core curriculum
This section shines once you’ve finished the core phases. The ideas are identical — you’re only learning new spelling.
Variables
1SET NAME = "Sara"2SET AGE = 123DISPLAY NAME, AGE1<?php2$name = "Sara";3$age = 12;4echo $name . " " . $age;1let name = "Sara";2let age = 12;3console.log(name, age);✨ The logic didn’t change. Only the syntax changed.
Input & output
1TAKE A, B2SET C = A + B3DISPLAY C1<?php2$a = (int) readline("A: ");3$b = (int) readline("B: ");4$c = $a + $b;5echo $c;1const a = Number(prompt("A:"));2const b = Number(prompt("B:"));3const c = a + b;4console.log(c);✨ The logic didn’t change. Only the syntax changed.
Conditions
1IF MARKS >= 60 THEN2 DISPLAY "Pass"3ELSE4 DISPLAY "Try again"5END IF1<?php2if ($marks >= 60) {3 echo "Pass";4} else {5 echo "Try again";6}1if (marks >= 60) {2 console.log("Pass");3} else {4 console.log("Try again");5}✨ The logic didn’t change. Only the syntax changed.
Loops
1FOR I = 1 TO 52 DISPLAY I3END FOR4 5WHILE N > 06 SET N = N - 17END WHILE1<?php2for ($i = 1; $i <= 5; $i++) {3 echo $i;4}5 6while ($n > 0) {7 $n = $n - 1;8}1for (let i = 1; i <= 5; i++) {2 console.log(i);3}4 5while (n > 0) {6 n = n - 1;7}✨ The logic didn’t change. Only the syntax changed.
Functions
1FUNCTION ADD(A, B)2 RETURN A + B3END FUNCTION4 5DISPLAY ADD(10, 20)1<?php2function add($a, $b) {3 return $a + $b;4}5 6echo add(10, 20);1function add(a, b) {2 return a + b;3}4 5console.log(add(10, 20));✨ The logic didn’t change. Only the syntax changed.
Collections
1SET NUMS = [5, 8, 2]2ADD 9 TO NUMS3FOR EACH N IN NUMS4 DISPLAY N5END FOR6SET AGES = {"Ali": 12}1<?php2$nums = [5, 8, 2];3$nums[] = 9;4foreach ($nums as $n) {5 echo $n;6}7$ages = ["Ali" => 12];1const nums = [5, 8, 2];2nums.push(9);3for (const n of nums) {4 console.log(n);5}6const ages = { Ali: 12 };✨ The logic didn’t change. Only the syntax changed.