Extra holiday's JS exericises Öffentlich

Extra holiday's JS exericises

Kostas Diakogiannis
Kurs von Kostas Diakogiannis, aktualisiert more than 1 year ago Beitragende

Beschreibung

Extra exercises for whoever wants to keep himself/herself relevant through holiday's time.

Modulinformationen

Keine Merkmale angegeben

Kontext

Find the forbidden word Create a function that accepts a sentence as an argument (a string) and checks if this sentence contains one of the forbidden words you have predefined. If it does print to the console something like ('The message cannot be printed because it contains inappropriate words'). Otherwise print the sentence itself. Predefine 5 forbidden words and put them in an array before creating the function. Thus it would be easier to check every word if it is included to the forbidden array of words or not.  hint; You may want to refresh the strings split and the arrays includes method before starting.
Weniger sehen
Keine Merkmale angegeben

Kontext

Print all favorite colors Store into an array of strings all the colors that you like // example ['navy blue', 'lightgreen', 'brown' , 'rebeccapurple']. Then print a phrase to console without using a loop that is like this 'My favorite colors among others are: navy blue, lightgreen, brown, rebeccapurple.'   Make this the most reusable way you know, so it can be expanded for favorite foods, favorite places to visit and many other types of arrays and collection you may think.   hint; You may want to revisit the array join method before proceeding further.
Weniger sehen
Keine Merkmale angegeben

Kontext

Print the city of every Fan of a specific team Create an array that contains 10 objects. Every object holds information about a person. The attributes that are being stored for every person are:  his first name, his last name, his favorite team, and the city that he lives in.   So all of them are typeof strings.   Create a global function that accepts a specific team as an argument, loops through all the objects of the array and prints the city of the person only if he supports the team that is specified in the parameter. In other words the function  printCityOf Fans('Dortmund') is going to print the city of living of all the fans (objects inside the array) that have 'Dortmund' as a favorite team. hint; You may want to recall how to loop through an array and also how to use the new constructor for creating multiple objects from a template.
Weniger sehen
Keine Merkmale angegeben

Kontext

Return abbreviated strings Write a function that accepts a string and returns and abbreviated form of it. So for each word converts it to uppercase and takes the first letter from it.    hint; You may want to recall how to split a string into an array for having access to each word. Then convert every word to upper case (there is a method for that) and extracting the first letter of each word (words have indexes or what) and push it into a new array where you store everything. Then you may want to join the latest array into one string.   in the end when you call the funciton returnAbbr('I write this text from Amsterdam') it should return 'IWTTFA'.
Weniger sehen
Keine Merkmale angegeben

Kontext

Show affordable items Create 10 objects that contain only two properties each. The name of a supermarket item, and it's price in $. let bananas = {item: 'Banana', cost: 2}; let onions = {item: 'Onion',  cost: 1}'   Store 10 of them in an array. Create a budget variable that represents the money you have in your wallet. Iterate through the array, and print the item property for every object that is affordable, for every object that your budget is bigger than item's cost. Try to place the budget also as an argument in order to make this the most re-usable way you can.
Weniger sehen
Keine Merkmale angegeben

Kontext

Summarize the products Imagine that  you sell 3 species of electronic equipment. Smartphones, laptops and air coolers.   An array that is called sales, holds the information about which kind has been solved. You hold there from the beginning the last 10 sales. ex:   let sales = ['smartphone', 'smartphone', 'laptop', 'smartphone', 'laptop', 'air cooler',  'smartphone', 'smartphone', 'laptop', 'smartphone'];   This array shows that have been solved until now 6 smartphones, 3 laptops and 1 air cooler.   Create a function that accepts an array of sold items (like sales) and returns an object with keys the string of the item ('smartphone', 'laptop', 'air cooler' etc) and a property the number of sold from this material.  For example. the function showQuantity(sales) is going to give back    // { smartphone: 6, laptop: 3, air cooler: 1 } Make this the most re-usable way you can. You may want to remind yourself both ways for adding properties into an object. Especially one of those is going to untie your hands.
Weniger sehen
Zusammenfassung anzeigen Zusammenfassung ausblenden