Skip to content

Instantly share code, notes, and snippets.

@ShaileshPrajapati-BTC
Last active February 19, 2019 08:47
Show Gist options
  • Save ShaileshPrajapati-BTC/42cfbd273842c1cb6e1c0cb54d98afe5 to your computer and use it in GitHub Desktop.
Save ShaileshPrajapati-BTC/42cfbd273842c1cb6e1c0cb54d98afe5 to your computer and use it in GitHub Desktop.
1 Write a JavaScript program to create a new string adding "Py" in front of a given string. If the given string begins with "Py" then return the original string.
2 Write a JavaScript program to create a new string from a given string changing the position of first and last characters. The string length must be greater than or equal to 1
3 Write a JavaScript program to check if the last digit of the three given positive integers is the same.
4 Write a JavaScript program to reverse a given string.
5 Write a JavaScript program to rotate the elements left of a given array of integers of length 3.
6 Write a JavaScript program to find the larger value between the first or last and set all the other elements with that value.
7 Write a JavaScript program to find the number which appears most in a given array of integers.
8 Write a JavaScript program to find the number of times to replace a given number with the sum of its digits until it converts to a single digit number.
9 Write a JavaScript program to check whether a matrix is a diagonal matrix or not. In linear algebra, a diagonal matrix is a matrix in which the entries outside the main diagonal are all zero (the diagonal from the upper left to the lower right).
Example:
[1, 0, 0], [0, 2, 0], [0, 0, 3] ]) = true
[1, 0, 0], [0, 2, 3], [0, 0, 3] ]) = false
10 Write a JavaScript program to reverse the order of the bits in a given integer.
56 -> 111000 after reverse 7 -> 111
234 -> 11101010 after reverse 87 -> 1010111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment