Published
Edited
Feb 27, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Math.random()
Insert cell
Insert cell
function myRandom(min , max= 0) {
return Math.random() * (max - min) + min
}
// trying to write the correct function

Insert cell
myRandom(2,4)
//testing out my function by giving min and max inputs
Insert cell
myRandom(3)
//testing my function by only giving the higher number only
Insert cell
function testmyRandom (min,max, testnumber)
{
if( testnumber > min && testnumber < max ){
return "true"}
else{
return "false"}
}
//not sure how to write a tester function to see if another function works..
//You would build a function that takes 3 numbers. A min, a max, and a number. The function will return true if the number is within the min and max, and false otherwise.

Insert cell
testmyRandom(4,6,5)
// Your code here

Insert cell
testmyRandom(4,6,7)
Insert cell
Insert cell
bestsellers = ["Jungle Book" ,"Goodnight Moon", "Rainbow Fish"]
Insert cell
md `The number bestseller today is ${bestsellers[2]}`
//trying to figure out some way to reference this element in the array without a function
Insert cell

function bestsellerfunction(bestsellers,N) {
return "The number" + N + "bestseller today is" + bestsellers[N]
}

// Your code here
//You will have an array of best seller titles. Your function will print the Nth title from that array
Insert cell
bestsellerfunction(bestsellers,2)
//this is as close as I could get but I cant figure out the spacing

Insert cell
function bestsellerfunction2(i) {
for( var i = i; i <4; i++ ) {
return "The number" + i + "bestseller today is" + bestsellers[i]
}
}
//trying to write a function with option inputs. not sure

Insert cell
bestsellerfunction2 (1)
//seems to work in some way?

Insert cell
Insert cell
function passfunc(password) {
if (password.length >8 && password.length< 14
&& /\d/.test(password)) //checks if there is a number
//&& password.includes("!" || "@" || "?") ) //trying to add in otdrt
{return "success"
}
else {
return "not a sucess" }
}

//trying not seeming to work.// finally got something to work.

Insert cell
passfunc("wertyuip2")
//trying to check the first condition
//finally got this length one to work! yay!
Insert cell
function passfunc2(password){
var regex = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/g;
return regex.test(password);
}
//contains at least on special character// cant figure out how to merge with other list of conditionals.

Insert cell
passfunc2("vgdgf!")
// checking for presence of at least one special character
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function exp(digit1, digit2){
for (var i = 0, i = digit2, ++i)
return digit1
}
// Your code here

Insert cell
Insert cell
function myminmax(somearray) {
let
for (var i = 1, , i++)
}
return [min,max]
}

// Your code here


//
function findMinMax(arr) {
let min = arr[0].y, max = arr[0].y;

for (let i = 1, len=arr.length; i < len; i++) {
let v = arr[i].y;
min = (v < min) ? v : min;
max = (v > max) ? v : max;
}

return [min, max];
}
Insert cell
Insert cell
// Your code here

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