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.
142 lines
3.5 KiB
JavaScript
142 lines
3.5 KiB
JavaScript
1 year ago
|
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{
|
||
|
key:'data type',
|
||
|
name:'John',
|
||
|
age:39,
|
||
|
ismarried:false,
|
||
|
petName:'baste'
|
||
|
}
|
||
|
|
||
|
};
|
||
|
const user =getUserInfo();
|
||
|
console.log(user);
|
||
|
|
||
|
|
||
|
/*
|
||
|
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 ['Eraserheads','Parokya ni Edgar','Rivermaya','The Dawn','Kamikazee']
|
||
|
};
|
||
|
const artist = getArtistsArray();
|
||
|
console.log(artist);
|
||
|
|
||
|
/*
|
||
|
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','Buwan','Call me maybe','Ikaw','Sana']
|
||
|
|
||
|
};
|
||
|
const song = getSongsArray();
|
||
|
console.log(song);
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
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 ['The hows of us','Barbie','Alone Together','Cant jelp falling in love','Hello love Goodbye']
|
||
|
};
|
||
|
|
||
|
const movies = getMoviesArray();
|
||
|
console.log(movies);
|
||
|
/*
|
||
|
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 [2,3,5,7,11]
|
||
|
}
|
||
|
const number = getPrimeNumberArray();
|
||
|
console.log(number);
|
||
|
|
||
|
|
||
|
//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){
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|