Skip to content

Instantly share code, notes, and snippets.

@xamQrexii
Last active January 21, 2021 18:07
Show Gist options
  • Save xamQrexii/32438ae0a16418088a7ba2f261f2e38a to your computer and use it in GitHub Desktop.
Save xamQrexii/32438ae0a16418088a7ba2f261f2e38a to your computer and use it in GitHub Desktop.
Tasks # 2
/**
|--------------------------------------------------
| TASK 1
|--------------------------------------------------
*/
Write a JavaScript program to generate a random integer.
/**
|--------------------------------------------------
| TASK 2
|--------------------------------------------------
*/
Write a JavaScript program to find the lowest value in an array.
Test data: [12,34,56,1], [-12,-34,0,-56,-1]
/**
|--------------------------------------------------
| TASK 3
|--------------------------------------------------
*/
Write a JavaScript program to check to check whether a value is numeric or not.
Test data: 12, "abcd", "12", '12', " ", 1.20, -200
/**
|--------------------------------------------------
| TASK 4
|--------------------------------------------------
*/
Write a JavaScript program to calculate the sum of values in an array
Test data: [1,2,3,10,20,85]
/**
|--------------------------------------------------
| TASK 5
|--------------------------------------------------
*/
What is the output of the following:
var num1 = 10;
var num2 = -5;
var result = --num1 + ++num2 + num2++ - num1-- + num1 - num2
Try to solve by doing dry run.
/**
|--------------------------------------------------
| TASK 6
|--------------------------------------------------
*/
Write a JavaScript program to check whether a string is blank or no.
Test data: "Osama", " ", ""
/**
|--------------------------------------------------
| TASK 7
|--------------------------------------------------
*/
Write a JavaScript program to capitalize the first two letters of a string.
Test data: "js exercises"
/**
|--------------------------------------------------
| TASK 8
|--------------------------------------------------
*/
Write a JavaScript function to capitalize the first letter of each word in a string
/**
|--------------------------------------------------
| TASK 9
|--------------------------------------------------
*/
Write a JavaScript program to count the occurrence of a substring in a string.
Test Data:
var sentence = "The Quick Brown fox jumps over the lazy dog"
var occurWord: "the"
/**
|--------------------------------------------------
| TASK 10
|--------------------------------------------------
*/
Write a JavaScript program to truncate a string to a certain number of words.
Test Data:
var sentence = 'The quick brown fox jumps over the lazy dog'
var noOfWords = 4;
Output:
"The quick brown fox"
@SyedAsadRazaDevops
Copy link

Ok sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment