Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check Whether Even or Odd
- function fun1(n){
- if (Number.isInteger(n)){
- if (n==0){
- console.log("Zero is neither Even nor Odd")}
- else if(n%2==0){
- console.log("GIven number is Even")
- }
- else
- console.log("Given number is Odd")
- }
- else
- console.log("Input is not a valid Number")
- }
- // Generate Even and Odd Number less than N and Generate βNβEven and Odd Numbers
- var Even=[];
- var Odd=[];
- var allEven=[];
- var allOdd=[];
- function OrN(n){
- if(Number.isInteger(n)){
- if(n==0){
- console.log("Zero is Even nor Odd")
- }
- else if (n%2==0){
- for (i=n;i>=2;i=(i-2)){
- Even.push(i-2);
- Odd.push(i-1);
- }
- }
- else{
- for (i=n;i>=2;i=(i-2)){
- Even.push(i-1);
- Odd.push(i-2);
- }
- }
- for (x=0;x<(2*n);x=(x+2)){
- allEven.push(x+2);
- allOdd.push(x+1);
- }
- }
- else{
- console.log("Invalid Input")
- }
- console.log(Odd);
- if (n%2==0)
- console.log(Even.slice(0,Even.length-1));
- else
- console.log(Even);
- console.log(allOdd);
- console.log(allEven);
- }
- //to decide given N is Prime or not
- function isPrime(n) {
- if(num < 2) return false;
- var prime = n != 1;
- for(var i=2; i<num; i++) {
- if(n % i == 0) {
- prime = false;
- break;
- }
- }
- return prime;
- }
- // prints the numbers from 1 to 100 and for multiples of '3' print"Fizz" instead of the number and
- for the multiples of '5' print "Buzz".
- function ran(){
- for(i=1;i<=100;i++){
- if(i%3==0){
- console.log("Fizz")
- }
- else if(i%5==0){
- console.log("Buzz")
- }
- else
- console.log(i)
- }
- }
- //Sum of Array Elements
- function sumArray(array) {
- for (let index = 0,length = array.length,sum = 0; index < length;sum += array[index++]);
- return sum;
- }
- //check whether given character is vowel or consonant
- let vowels=[a,e,i,o,u];
- let consonants=[b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z];
- function VoC(){
- for (int i = 0; i < vowels.length-1; i++) {
- for (int k = i + 1; k < vowels.length-1; k++) {
- if(vowels[i]=vowels[k]){
- console.log("vowel");
- }
- else
- console.log("Consonent")
- }
- }
- }
- // the largest number among three numbers
- function bigAmong(a,b,c){
- if (a>b){
- if(a>c){
- console.log("A is greatest");
- }
- else
- console.log("C is the greatest");
- }
- else if (b>c){
- console.log("B is greatest");
- }
- else
- console.log("C is greatest");
- }
Add Comment
Please, Sign In to add comment