Here, I created a new array of just the names in __myData__. If you want to copy all the values in your array, and add some new ones, you can use the __{...}__ notation.
return`My first name is ${firstName}, and my last name is ${lastName}.`
}
[1,2,3,4,5].filter(d=>d<3)
[1,2,3,4,5].filter(function(d){returnd<3})
{
if(1>2){
return'Math is broken'// If this statement is true return this
}else{
return'Math still works!'// If the first statement was false, return this
}
}
{
if(1>2){
return'Math is broken'// If this statement is true, return this
}elseif(1=='1'){//
return'Math works?'// If the second statement is true, return this
}else{
return'Math is an synthetic a priori truth'// If neither statements were true, return this
}
}
1==1
1=='1'
1==='1'
{
if(1>2){// If this statement is true
return'Math is broken'// return this
}else{// if the first statement was not true
return'Math still works!'// return this
}
}
variableSetToCodeBlock={
consttoday=newDate();
returntoday.getFullYear()
}
{
letstring=''
for(leti=0;i<=5;i++){
string+=i
}
returnstring
}
myValues=[1,20,13,4,55,6]
{
letlargestNumber=0;// Declare a variable for the largest number
for(leti=0;i<myValues.length-1;i++){// Loop through all the values in my array
if(myValues[i]>largestNumber){// Check if the value in the array is larger that the largestNumber
largestNumber=myValues[i]// If so, assign the value as the new largest number
}
}
returnlargestNumber
}
d3.max(myValues)
{
letlargestNumber=0;// Create a variable for the largest number
leti=0;
while(i<myValues.length-1){
if(myValues[i]>largestNumber){// Check if the value in the array is larger that the largestNumber
largestNumber=myValues[i]// If so, assign the value as the new largest number
}
i++;
}
returnlargestNumber
}
{
constwidth=300;
constheight=100;
constr=30;
constsvg=d3.create('svg')
.attr('width',width)
.attr('height',height);
constcircle=svg.append('circle')
.attr('r',r)
.attr('cy',height/2)
.attr('cx',r);
letcx=30;
while(true){// Loop goes on forever
yieldsvg.node();
awaitPromises.delay(2000);// This causes the loop to "wait" 1200 milliseconds
cx==r?cx=width-r:cx=r;
circle.transition()
.duration(1500)
.attr('cx',cx);
}
}
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.