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' ]
27. Create a function that takes a string and returns a string in which each character is repeated once.
functiondoubleChar(str){//Write Your solution Here};console.log(doubleChar('jahidul'));//jjaahhiidduullconsole.log(doubleChar('islam'));//iissllaammconsole.log(doubleChar('zim'));//zziimm
28. Write a function that takes a positive integer and return its factorial.
functionfactorial(num){//Write Your solution Here};console.log(factorial(5));//120console.log(factorial(10));//3628800console.log(factorial(8));//40320
31. Create a function that takes a string and returns the number (count) of vowels contained within it.
functioncountVowels(str){//Write Your solution Here};console.log(countVowels('Jahidul Islam zim'));// 6console.log(countVowels('returns the number of vowels'));// 8console.log(countVowels('JavaScript Coding Challenges'));// 8
32. Create a function that takes two vectors as arrays and checks if the two vectors are orthogonal or not. The return value is boolean. Two vectors a and b are orthogonal if their dot product is equal to zero.
functionisOrthogonal(arr1,arr2){//Write Your solution Here};console.log(isOrthogonal([1,-2,4],[2,5,2]));//trueconsole.log(isOrthogonal([1,-2,5],[2,5,2]));//falseconsole.log(isOrthogonal([1,2,4],[-2,5,-2]));//true
33. Given an object of how many more pages each ink color can print, output the maximum number of pages the printer can print before any of the colors run out.
34. Create a function that takes a string and returns a new string with all vowels removed.
functionremoveVowels(str){//Write Your solution Here};console.log(removeVowels('Jahidul Islam Zim'));//Jhdl slm Zmconsole.log(removeVowels('a new string with all vowels'));// nw strng wth ll vwlsconsole.log(removeVowels('Create a function'));//Crt fnctn
36. Given an array of scrabble tiles, create a function that outputs the maximum possible score a player can achieve by summing up the total number of points for all the tiles in their hand. Each hand contains 7 scrabble tiles.
37. Assume a program only reads .js or .jsx files. Write a function that accepts a file path and returns true if it can read the file and false if it can't.
functionisJS(path){//Write Your solution Here};console.log(isJS('file.jsx'));//true console.log(isJS('file.jsg'));//falseconsole.log(isJS('file.js'));//true
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.