JSFiddle - React, Tailwind, and code Playground
by lavisha99
JavaScript
function number(nom) {
let NoArray = [];
for(let i=0; i<nom; i++){
let rndNo = Math.floor(Math.random()*100);
NoArray.push(rndNo);
}
return NoArray;
}
console.log(number(4));
/* PROBLEM 2
Write a function that receives an array of numbers and returns the
smallest number.
*/
/*
function smallNo(arrayNo){
this.arrayNo = arrayNo;
var smallestNo = arrayNo[0] ;// arrayNo
//this.see= function(){
for(let i=0; i<arrayNo.length; i++){
if
(arrayNo[i]<smallestNo){
smallestNo = arrayNo[i];
}
}
console.log("The smallest number is " + smallestNo);
/*//*/
}
let ans = new smallNo([234,2,,4,6])
//let final = ans.see();
*/
function bigNo(arrayNo){
this.arrayNo = arrayNo;
var biggestNo = arrayNo[0] ;// arrayNo
//this.see= function(){
for(let i=0; i<arrayNo.length; i++){
if
(arrayNo[i]>biggestNo){
biggestNo = arrayNo[i];
}
}
console.log("The smallest number is " +biggestNo);
/*//*/
}
let ans = new bigNo([234,244,,4,6])
//let final = ans.see();