console.log(`Iteration number ${i}`)// Remember that the output will show up in the Console.
}
}
{
letcurrVall=0;
for(letval=0;val<20;val++){
currVall+=val;
console.log("Hello World +",val,"goodbye");
}
returncurrVall;
}
{
for(vari=0;i<10;i++){
console.log(`Iteration number ${i}`)// Remember that the output will show up in the Console.
}
returni
}
{
letmyArray=[0,1,2,3,4];
for(vari=0;i<5;i++){
console.log("accessing an array",myArray[i],i);// Remember that the output will show up in the Console.
}
returnmyArray[i-1];
}
{
letmyArray=["my","new","array"];
for(varwhateverinmyArray){
console.log(myArray[whatever],whatever);
}
returnmyArray;
}
{
letarray=[0,1,2,3,4];
for(variinarray){
array[i]=array[i]**2;
}
returnarray;
}
{
varcounter=0
while(counter<5){
console.log(`The counter is ${counter}, which is less than 5.`)
counter+=1
};
returncounter
}
{
for(vari=0;i<5;i++){
console.log('accessing an array',i)// Remember that the output will show up in the Console.
}
}
{
constnum=100
if(num==100){
return"100!"
}
else{
return"Not 100..."
}
}
{
constnum=100
if(num==99){
return"99!"
}
else{
return"Not 99..."
}
}
{
varnumber=100
if(number==100){
return"Number is 100"
}elseif(number<100){
return"Number is less than 100."
}elseif(number>100){
return"Number is greater than 100."
}};
// function declaration with parameters
functionmultiply_this(number1,number2){
returnnumber1*number2
}
multiply_this(5,2)
functionempty(){
return'hello world'
}
hello=empty()
{
// call the function, providing arguments for the parameters
constx=4
consty=5
returnmultiply_this(x,y)// run function with x and y as our arguments
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.