You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
05. Write functions to calculate the bitwise AND, bitwise OR and bitwise XOR of two numbers.
functionbitwiseAND(n1,n2){//Write Your solution Here};functionbitwiseOR(n1,n2){//Write Your solution Here};functionbitwiseXOR(n1,n2){//Write Your solution Here};console.log(bitwiseAND(10,20));// 0console.log(bitwiseOR(10,20));// 30console.log(bitwiseXOR(10,20));// 30
18. Your function will be passed two functions, f and g, that don't take any parameters. Your function has to call them, and return a string which indicates which function returned the larger number.
If f returns the larger number, return the string f.
If g returns the larger number, return the string g.
If the functions return the same number, return the string neither.
functionwhichIsLarger(f,g){//Write Your solution Here};console.log(whichIsLarger(()=>25,()=>15));// fconsole.log(whichIsLarger(()=>25,()=>25));// neitherconsole.log(whichIsLarger(()=>25,()=>50));// g
19. Christmas Eve is almost upon us, so naturally we need to prepare some milk and cookies for Santa! Create a function that accepts a Date object and returns true if it's Christmas Eve (December 24th) and false otherwise. Keep in mind JavaScript's Date month is 0 based, meaning December is the 11th month while January is 0.
functiontimeForMilkAndCookies(date){//Write Your solution Here};console.log(timeForMilkAndCookies(newDate(3000,11,24)));//trueconsole.log(timeForMilkAndCookies(newDate(2013,0,23)));//falseconsole.log(timeForMilkAndCookies(newDate(3000,11,24)));//true
20. function that takes a two-digit number and determines if it's the largest of two possible digit swaps.
functionlargestSwap(num){//Write Your solution Here};console.log(largestSwap(14));//falseconsole.log(largestSwap(53));//trueconsole.log(largestSwap(-27));//false
21. function that takes two strings as arguments and returns the number of times the first string (the single character) is found in the second string.
functioncharCount(myChar,str){//Write Your solution Here};console.log(charCount("a","largest"));//1console.log(charCount("c","Chamber of secrets"));// 2console.log(charCount("b","big fat bubble"));//4
22. function that takes two parameters and repeats the string n number of times.
functionrepetition(txt,n){//Write Your solution Here};console.log(repetition('zim',5));//zimzimzimzimzimconsole.log(repetition('zoy',2));//zoyzoyconsole.log(repetition('akib',7));//akibakibakibakibakibakibakib
24. Write a function that take a string and write a regular expression inner function that returns the value that matches every red flag and blue flag in this string.
functionmatchFlag(str){//Write Your solution Here};console.log(matchFlag("yellow flag red flag blue flag green flag"));//[ 'red flag', 'blue flag' ]console.log(matchFlag("yellow flag green flag orange flag white flag"));//nullconsole.log(matchFlag("yellow flag blue flag green flag"));//[ 'blue flag' ]
Hello JavaScript code newbie! In this repository I'm proposing you a series of coding challenges that will help you practice the basic language constructs and algorithms.