- Notifications
You must be signed in to change notification settings - Fork307
JavaScript Pretest 1
- Use the names array of the students who you have been introduced today.
- Write a function called greetStudents, which take an array of names. Use your function to greet all the your classmates.
constnames=['Pradip','Van','Thanh','Thanh','Ca','Joshua','Devendra','Anzhelika']console.log(greetStudents(names))HiAngelica,nicetomeetyou.IamAsabeneh.WelcometoIntegrify. ...
1. Write a function called greet which take name and role as parameters. Use your function to greet all the your classmates.console.log(greet('Asabeneh','teacher'))HiAngelica,nicetomeetyou.IamAsabenehandIamateacherhereatIntegrify.WelcometoIntegrify.console.log(greet('Van'))HiAngelica,nicetomeetyou.IamVanandIamastudenthereatIntegrify.WelcometoIntegrifyconsole.log(greet('Joshua'))HiAngelica,nicetomeetyou.IamJoshuaandIamastudenthereatIntegrify.WelcometoIntegrify
Extract the numbers and calculate the total annual income of the person from the following text. ‘He earns 5000 euro from salary per month, 15000 euro annual bonus, 10000 euro online courses per month.’
In English language some words come more often than others to a sentence. Write a function calledmostFrequentWords it takes a sentence or a paragraph as a parameter and return an array of objects. The object key is the word and its number of occurrence is the value. What are the ten most frequent words in a sentence or a paragraph of an English language.
console.log(mostFrequentWords(paragraph))
Write a function called sumOfNumbers. It takes unlimited number of integers as parameters and it returns the sum.
- Implement this function using function declaration
- Implement this function using arrow function
Write a function called stat which calculate mean, median and range of an array.
constnumbers=[80,85,70,90,65,90,80];stat(numbers).mean()stat(numbers).median()stat(numbers).range()
- A junior developer structure student name, skills and score in array of arrays which may not easy to read. Destruction the following array name to name, skills array to skills, scores array to scores, JavaScript score to jsScore and React score to reactScore variable.
conststudent=['David',['HTM','CSS','JS','React'],[98,85,90,95]]console.log(name,skills,scores)console.log(jsScore,reactScore)
- Write a function called convertArrayToObject which can convert the array to a structured object.
conststudents=[['David',['HTM','CSS','JS','React'],[98,85,90,95]],['John',['HTM','CSS','JS','React'],[85,80,85,80]]]console.log(convertArrayToObject(students))[{name:'David',skills:['HTM','CSS','JS','React'],scores:[98,85,90,95]},{name:'John',skills:['HTM','CSS','JS','React'],scores:[85,80,85,80]}]
Copy the student object to newStudent without mutating the original object. In the new object add the following ?
- Add Bootstrap with level 8 to the front end skill sets
- Add Express with level 9 to the back end skill sets
- Add SQL with level 8 to the data base skill sets
- Add SQL without level to the data science skill sets
conststudent={name:'David',age:25,skills:{frontEnd:[{skill:'HTML',level:10},{skill:'CSS',level:8},{skill:'JS',level:8},{skill:'React',level:9}],backEnd:[{skill:'Node',level:7},{skill:'GraphQL',level:8},],dataBase:[{skill:'MongoDB',level:7.5},],dataScience:['Python','R','D3.js']}}``` The copied object output should look like this:```js{name:'David',age:25,skills:{frontEnd:[{skill:'HTML',level:10},{skill:'CSS',level:8},{skill:'JS',level:8},{skill:'React',level:9},{skill:'BootStrap',level:8}],backEnd:[{skill:'Node',level:7},{skill:'GraphQL',level:8},{skill:'Express',level:9}],dataBase:[{skill:'MongoDB',level:7.5},{skill:'SQL',level:8}],dataScience:['Python','R','D3.js','SQL']}}
The following are two different questions:
'Facebook, Google, Microsoft, Apple, IBM,Oracle, Amazon'. This string contains big IT companies. Write a function called companiesWithTwoOs check if the company has two os are return an array containing the companies.
Find out which letter is used many times as initial for a country name from thecountries array (eg. Finland, Fiji, France etc)
Write the function called tenMostSpokenLanaguages, it takes thecountriesobject and return the array of objects. The language is key and value is the number of places the language is spoken.
Make a function called add which give truthy value when add(a, b) === add(a)(b)
console.log(add(2,3))//5console.log(add(2)(3))//5console.log(add(2,3)===add(2)(3))// true
Write a function called checkDataTypes it takes an array and a data type. It returns true if all the array items are the same data types.
constnumbers=[1,3,4]constnames=['Asab','Eyob'];constbools=[true,false,true,true,false]constmixedData=['Asab','JS',true,2019,{name:'Asab',lang:'JS'}]constobject=[{name:'Asab',lang:'JS'}]console.log(checkDataTypes(numbers,'number'))// trueconsole.log(checkDataTypes(numbers,'string'))// falseconsole.log(checkDataTypes(names,'string'))// trueconsole.log(checkDataTypes(bool,'boolean'))// trueconsole.log(checkDataTypes(mixedData,'boolean'))// falseconsole.log(checkDataTypes(obj,'object'))// true