Published
Edited
Jul 3, 2022
5 stars
Also listed in…
Tips and Utilities
Insert cell
# Hello, sugar js!
Insert cell
Insert cell
Insert cell
Sugar = require('https://bundle.run/sugar@2.0.6')
Insert cell
Sugar.Number.random(1, 100);
Insert cell
Sugar.Date.create('next Friday');
Insert cell
Sugar.Array.unique([1,2,2,3]);
Insert cell
Sugar.Date.format(new Date(), '%Y-%m-%d');
Insert cell
{
var arr = new Sugar.Array([1,2]);
yield arr.concat([2,3]).unique().raw;
}
Insert cell
{
var num = new Sugar.Number(3.1415);
yield num.round(1).toFixed(2).raw
}
Insert cell
{
var date = new Sugar.Date('2 weeks ago');
yield date.raw;
}
Insert cell
Sugar.Number.range(5, 10).contains(8);
Insert cell
Sugar.String.range('a', 'z').toArray();
Insert cell
{var n = new Sugar.Number(5);
yield n.log().pow(2).round(2).raw;
}
Insert cell

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.
Learn more