You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.5 KiB
JavaScript

console.log('hello world');
/*
1. Create a function named getUserInfo which is able to return an object.
The object returned should have the following properties:
- key - data type
- name - String
- age - Number
- address - String
- isMarried - Boolean
- petName - String
Note: Property names given is required and should not be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getUserInfo(){
return {
name: 'john doe',
age: 23,
address:'123 street quezon city',
petName: 'Danny'
}
}
const myObject = getUserInfo();
console.log(myObject);
/*
2. Create a function named getArtistsArray which is able to return an array with at least 5 names of your favorite bands or artists.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getArtistsArray(){
return [ 'Chocolate factory', 'East Side', 'Paarokya ni Edgar','Silent Sanctuary','Taylor Swift']
}
const myObject1 = getArtistsArray();
console.log(myObject1);
/*
3. Create a function named getSongsArray which is able to return an array with at least 5 titles of your favorite songs.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getSongsArray(){
return [ 'Perfect', 'Dilaw', 'heaven knows','Sleeping Child','Through the Years']
}
const myObject2 = getSongsArray();
console.log(myObject2);
/*
4. Create a function named getMoviesArray which is able to return an array with at least 5 titles of your favorite movies.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getMoviesArray(){
return[ 'Titanic','Snowhite','Mermaid','Moana','Encanto']
}
const myObject3 = getMoviesArray();
console.log(myObject3)
/*
5. Create a function named getPrimeNumberArray which is able to return an array with at least 5 prime numbers.
- Note: the array returned should have numbers only.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getPrimeNumberArray(){
return[ 11, 13,17,19,23]
}
const myObject4 = getPrimeNumberArray();
console.log(myObject4);
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
getUserInfo: typeof getUserInfo !== 'undefined' ? getUserInfo : null,
getArtistsArray: typeof getArtistsArray !== 'undefined' ? getArtistsArray : null,
getSongsArray: typeof getSongsArray !== 'undefined' ? getSongsArray : null,
getMoviesArray: typeof getMoviesArray !== 'undefined' ? getMoviesArray : null,
getPrimeNumberArray: typeof getPrimeNumberArray !== 'undefined' ? getPrimeNumberArray : null,
}
} catch(err){
}