This is a programming language made in JavaScript for beginners, who want to learn programming basics. It was made for fun so there may be some bugs.
This repository is actually a web version of this language, so you dont need to install any packages, just go to the domain of the language and code!
variables that can be changed are created with “var”:
var x = 1
constants, in another words variables, that can’t be changed are initialized with a keyword “const”, just like in JavaScript!:
const x = "you cannot change this variable lol"
Strings can be created with “”
const x = "you cannot change this variable lol"
Numbers(the same as integers)
const x = 1
Numbers(the same as integers)
const x = 5.5
Objects here are similar to JSON objects! :)
const x = { a: 5, b: "this is a string", c: { x: 67 } }
Arrays are like objects but its elements don’t have keys
const x = [1, "string", {a:1,b:5,c:true}]
Bools are either true or false
const x = [true,false]
Bools in this language are not real, they are native variables and get evaluated into 0 or 1
Null is empty value
var x = null
So functions is very interesting in this language - it can behave like a class
task main(){
task add(a,b){
write(a+b)
}
task substract(a,b){
write(a-b)
}
}
const func = main() //-> runs main, and gets every function and variable in the main
func.add(5,8)
func.substract(67,5)
Or functions can be normal functions:
task helloworld(){
write("hello world!")
}
helloworld()
There are multiple binary operations in EasyLang:
write(2+2)
write(2-2)
write(2*2)
write(2/2)
write(10%3)
There are also many logical binary operations in EasyLang:
write(false and true) // -> output must be 0, so false
write(true or 2) // -> output must be 1, so true
write(2<3) // -> output must be 1, so true
write(3<=2) // -> output must be 0, so false
write(10>3) // -> output must be 1, so true
write(3>=3) // -> output must be 1, so true
write(2+2==4) // -> output must be 1, so true
If statements in EasyLang are very simple -> if keyword, condition, body:
var x = 5
if(x==5){
write("x is 5!")
}
You can do also if-else statement:
var x = 6
if(x<5){
write("x is less than 5!")
} else {
write("x is greater than 5!")
}
There are two types of loops: quick one and normal
Quick one:
loop(i:10){
write(i)
}
Normal one:
var i = 0
while(i<10){
write(i)
i=i+1
}
input()
-> takes input from user, unfortunately in browser if its in the loop it can freeze other script and ui until the loop ends :(write()
-> simply outputs the valueint()
-> takes a value as an argument and returns the parsed number versiontoString()
-> takes a value as an argument and returns the parsed string versionmath.sqrt()
-> takes a number as an argument and returns its square rootmath.Pi
-> returns Pimath.round()
-> takes a number as an argument and returns the nearest integermath.cos()
-> takes a number as an argument and returns its cosinemath.sin()
-> takes a number as an argument and returns its sinemath.random()
-> takes a minimum and maximum value as arguments and returns a random number between themstring.len(string)
-> returns length of the stringstring.split(string, char)
-> splits the string into an array and returns itstring.matches(string, pattern)
-> takes a string and a regular expression as arguments and returns the match(IMPORTANT! As the second argument you need to input regexp without slashes, so like this -> ‘^(hello)’)string.replace(string, target, replacement)
-> returns a copy of the string where all occurrences of target are replaced with replacement