You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
"This is a string".charAt(0); // = 'T'"Hello".length(); // = 5
"This is a string".charAt(0);// = 'T'"Hello".length;// = 5
Truthy / Falsy
Java
Javascript
null
null;undefined;// false, null, undefined, NaN, 0 and "" are falsy; everything else is truthy.// Note that 0 is falsy and "0" is truthy, even though 0 == "0".
Variables
Java
Javascript
Stringname = "Manusia bernapas";
intage = 12;
booleanhasHighscore = true;
inta = 0, b = 0, c = 0;
// sebenernya bisa pake class// tapi nanti di Javascript juga ada class yang lebih mirip// class di Javascript under the hood itu pakenya object juga// tapi dikasih syntactical sugar biar mirip kaya class biasanya
intnumber = 2;
if (number > 2) {
System.out.println("Number is bigger than 2");
} elseif (number == 2) {
System.out.println("Number is equal to 2");
} else {
System.out.println("Number is smaller or equal to 2");
}
constnumber=2;if(number>2){console.log("Number is bigger than 2");}elseif(number===2){console.log("Number is equal to 2");}else{console.log("Number is smaller or equal to 2");}
while (condition) {
// do something
}
while(condition){// do something}
do {
// do something
} while (condition)
do{// do something}while(condition)
for (inti = 0; i < 10; i++) {
System.out.println(i);
}