Learn CODEORG-BLOCKLY with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Hello World in Code.org Blockly (JavaScript view)
console.log("Hello World")
A simple Code.org Blockly project that displays 'Hello World'. The blocks correspond to this JavaScript output.
2
Repeat Loop Example
for(let i=0;i<5;i++) {
console.log("Iteration " + i)
}
Repeats an action 5 times using Blockly repeat block.
3
If Statement Example
let score = 80
if(score >= 50) {
console.log("Passed")
}
Checks a condition and prints a message if true.
4
Variable Assignment Example
let name = "Alice"
console.log("Hello, " + name)
Creates a variable and prints its value.
5
Simple Math Operation
let a = 5
let b = 7
console.log(a + b)
Adds two numbers and prints the result.
6
Boolean Logic Example
let x = 10
let y = 20
if(x < 15 && y > 15) {
console.log("Both conditions true")
}
Uses boolean logic to check multiple conditions.
7
Function Example
function greet(person) {
console.log("Hello, " + person)
}
greet("Bob")
Defines a function and calls it to print a message.
8
Random Number Example
let rand = Math.floor(Math.random() * 10) + 1
console.log(rand)
Generates a random number between 1 and 10 and prints it.
9
Array Example
let fruits = ["apple", "banana", "cherry"]
for(let i=0;i<fruits.length;i++) {
console.log(fruits[i])
}
Creates an array and prints each element using a loop.
10
Simple Event Handling Example
function onClick() {
console.log("Button clicked")
}
onClick()
Simulates a click event in Blockly and prints a message.