Last active
January 3, 2021 08:28
-
-
Save xamQrexii/620a977ec8c6c4dd02efc5e8b6427ab1 to your computer and use it in GitHub Desktop.
Tasks # 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
|-------------------------------------------------- | |
| TASK 1 | |
|-------------------------------------------------- | |
*/ | |
Write a program that writes the current date in the following format. | |
====> Tue Dec 03 2019 | |
/** | |
|-------------------------------------------------- | |
| TASK 2 | |
|-------------------------------------------------- | |
*/ | |
Write a program that writes the current date in the following format. | |
====> Tue Dec 03 2019 14:53:48 GMT+0500 (Pakistan Standard Time) | |
/** | |
|-------------------------------------------------- | |
| TASK 3 | |
|-------------------------------------------------- | |
*/ | |
What will be the output of the following program? | |
const date = new Date(); | |
console.log("HOUR =======>", date.getHours()); | |
console.log("DAY =======>", date.getDay()); | |
console.log("MONTH =======>", date.getMonth()); | |
console.log("YEAR =======>", date.getFullYear()) | |
/** | |
|-------------------------------------------------- | |
| TASK 4 | |
|-------------------------------------------------- | |
*/ | |
What will be the output of the following program? | |
const date = new Date(); | |
console.log(new Date(date.setFullYear(2006)).toDateString()) | |
/** | |
|-------------------------------------------------- | |
| TASK 5 | |
|-------------------------------------------------- | |
*/ | |
Write a function that takes a name as a parameter and append Mr. at the start of the name on console | |
/** | |
|-------------------------------------------------- | |
| TASK 6 | |
|-------------------------------------------------- | |
*/ | |
Invoke the following function and determine the output. | |
function tellTime() { | |
var now = new Date(); | |
var theHr = now.getHours(); | |
var theMin = now.getMinutes(); | |
console.log("Current time: " + theHr + ":" + theMin) | |
} | |
/** | |
|-------------------------------------------------- | |
| TASK 7 | |
|-------------------------------------------------- | |
*/ | |
Point out the incorrect form of writing a function in javascript | |
1. myfunction() { } | |
2. function myfunction() { } | |
3. func myfunction() { } | |
4. myfunction = () => { } | |
/** | |
|-------------------------------------------------- | |
| TASK 8 | |
|-------------------------------------------------- | |
*/ | |
Write a function that takes an array as a parameter. | |
The function's duty is to delete the last element from the array and return the array | |
/** | |
|-------------------------------------------------- | |
| TASK 9 | |
|-------------------------------------------------- | |
*/ | |
Write a function that takes an argument. | |
The function's duty is to check the arguments type and print the type | |
For example if i pass in a string the function should print string on the console | |
if i pass a number the console should print number | |
/** | |
|-------------------------------------------------- | |
| TASK 10 | |
|-------------------------------------------------- | |
*/ | |
Write a function that takes an array of numbers as a parameter and function's job | |
is to multiply each element of an array by 2 and print it | |
/** | |
|-------------------------------------------------- | |
| TASK 11 | |
|-------------------------------------------------- | |
*/ | |
Write a function that does not get any arguments but should return a random id number if called against a variable | |
Example: | |
var id = generateId(); | |
the generate function should generate a random id between 1 - 1000 and return it | |
/** | |
|-------------------------------------------------- | |
| TASK 12 | |
|-------------------------------------------------- | |
*/ | |
Write a function that takes in a string as an argument an the functions duty is to check the number of characters | |
in a string a print it on the console | |
/** | |
|-------------------------------------------------- | |
| TASK 13 | |
|-------------------------------------------------- | |
*/ | |
write an arrow function that takes in a string as an argument and returns the string in uppercase letters. | |
/** | |
|-------------------------------------------------- | |
| TASK 14 | |
|-------------------------------------------------- | |
*/ | |
Write a function to sort an array of numbers in ascending or descending order | |
/** | |
|-------------------------------------------------- | |
| TASK 15 | |
|-------------------------------------------------- | |
*/ | |
Write a function and the functions duty is to first check | |
if the argument passed is a string..if it is then you should concatenate behind the sring "Welcome" and return it | |
if the argument passed is a number then it should be multiplied by the power of 2 and return it | |
/** | |
|-------------------------------------------------- | |
| TASK 16 | |
|-------------------------------------------------- | |
*/ | |
Write a function to round a number to a specified number of digits. when passed as an argument and return it | |
Example: | |
roundNumber(4.6); | |
Expected Ouput: 5 ===> The number is rounded off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment