Fall 2024 - P3
3.4.4 Javascript Hacks
Complete these hacks to demonstrate your understanding of the content
Hack 1
A student was instructed to provide a list of ALL the countries in Africa. Your task is to now convert the list, which is provided as a string and convert it to an array.
String: “Algeria, Angola, Benin, Botswana, Burkina Faso, Burundi, Cabo Verde, Cameroon, Central African Republic, Chad, Comoros, Congo (Congo-Brazzaville), Cote d’Ivoire, Djibouti, DR Congo (Congo-Kinshasa), Egypt, Equatorial Guinea, Eritrea, Eswatini, Ethiopia, Gabon, Gambia, Ghana, Guinea, Guinea-Bissau, Kenya, Lesotho, Liberia, Libya, Madagascar, Malawi, Mali, Mauritania, Mauritius, Morocco, Mozambique, Namibia, Niger, Nigeria, Rwanda, Sao Tome and Principe, Senegal, Seychelles, Sierra Leone, Somalia, South Africa, South Sudan, Sudan, Tanzania, Togo, Tunisia, Uganda, Zambia, Zimbabwe”
You must complete this hack using a string method
Hack 2
Applications that are more personalized are always great to have! Please create a program that prompts the user for their name, age, favorite food, & favorite book. Store all these prompts as variables and then use concatenation or interpolation to make a cohesive message out of these prompts.
To get you started, here’s how you can prompt someone in JavaScript: prompt("Please enter your name")
Hack 3
Part 1
We received this message from a noisy audio file: "The...secret...to...life...is...(redacted)"
There seems to be white noise in between words. Please remove the ...
between the words using a string method.
Expected output: “The secret to life is (redacted)”
Part 2
Once you figure out how to remove this white noise, we should create a program to remove it from any file! Please create a program that takes user input and can remove the … that may or may not be in the input.
Example input & output:
- Input:
Hello...World
- Output:
Hello World