Skip to content

Instantly share code, notes, and snippets.

@adnanirfan
Last active December 17, 2022 08:19
Show Gist options
  • Save adnanirfan/f23393253b7a66b0ff1732bfb4a01304 to your computer and use it in GitHub Desktop.
Save adnanirfan/f23393253b7a66b0ff1732bfb4a01304 to your computer and use it in GitHub Desktop.
Javascript Test - UIT Summer 2022
  1. Write a JavaScript function that reverse a number.

      Example x = 32243;
      Expected Output : 34223
    
  2. Write a JavaScript function that checks whether a passed string is palindrome or not?

      A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.
    
  3. Write a JavaScript function that generates all combinations of a string.

      Example string : 'dog'
      Expected Output : d,do,dog,o,og,g
    
  4. Write a JavaScript function that returns a passed string with letters in alphabetical order.

      Example string : 'webmaster'
      Expected Output : 'abeemrstw'
      Assume punctuation and numbers symbols are not included in the passed string.
    
  5. Write a JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case.

      Example string : 'the quick brown fox'
      Expected Output : 'The Quick Brown Fox '
    
  6. Write a JavaScript function that accepts a string as a parameter and find the longest word within the string.

      Example string : 'Web Development Tutorial'
      Expected Output : 'Development'
    
  7. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string.

      Note : As the letter 'y' can be regarded as both a vowel and a consonant, we do not count 'y' as vowel here.
      Example string : 'The quick brown fox'
      Expected Output : 5
    
  8. Write a JavaScript function that accepts a number as a parameter and check the number is prime or not.

      Note : A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
    
  9. Write a JavaScript function which accepts an argument and returns the type.

      Note : There are six possible values that typeof returns: object, boolean, function, number, string, and undefined.
    
  10. Write a JavaScript function which returns the n rows by n columns identity matrix.

  11. Write a JavaScript function which will take an array of numbers stored and find the second lowest and second greatest numbers, respectively.

     Sample array : [1,2,3,4,5]
     Expected Output : 2,4
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment