Public
Edited
Jul 22, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// add() takes in two arguments, both of which should be finite numbers, and returns their sum
function add(a, b) {
// Verify whether either of the two parameters are missing.
if(a === undefined || b === undefined)
throw Error("One or more parameters are missing from add()"); // Throw error
// Verify whether parameters are finite numbers by using Number.isFinite()
else if(Number.isFinite(a) && Number.isFinite(b))
return a + b; // Return sum
// Throw an error if both parameters are not numeric
else
throw Error("One or more parameters are not numeric"); // Throw error
}
Insert cell
Insert cell
add(23, 47);
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more