Skip to content

Codi-T02/JS-Basics-5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Basics-05 (Lab) (50x🔑)

In this exercise, you will solve logical problems using JavaScript (JS) and HTML.

Pre-requisites

  • FCC HTML & CSS
  • FCC JS & ES6
  • JS Basics 01
  • JS Basics 02
  • JS Basics 03
  • JS Basics 04

Goals

  • Solve problems using JavaScript
  • Learn basic programming algorithms
  • Competencies:
    • JS
    • Logic

Instructions

  • For each of the below problems, create a problemX.html file where X is the number of the problem
  • In each problem, you should take the input of the user using an input field and give output using script

Problems

  1. Write a program that asks the user for their name and greets them with their name. Commit "greetings" Example input: Omar Example output: Hello Omar
  2. Modify the previous program such that only the users Alice and Bob are greeted with their names. Commit "condition" Example input 1 : Omar Example output 1 : Hello Stranger Example input 2: Alice Example output 2: Hello Alice
  3. Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. Commit "loop" Example input: 5 Example output: 15
  4. Modify the previous program such that only multiples of three or five are considered in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17. Commit "multiples" Example input: 5 Example output: 8
  5. Write a program that asks the user for a number n and gives them the possibility to choose between computing the sum and computing the product of 1,…,n. Commit "sum or product" Example input 1: 5 + Example output 1: 15 Example input 2: 5 x Example output 2: 120
  6. Write a program that prints a multiplication table for numbers up to 12. Commit "multiplication table" Example output: 1: 1 2 3 4 5 6 7 8 9 10 11 12 2: 2 4 6 8 10 12 14 16 18 20 22 24 3: 3 6 9 12 15 18 21 24 27 30 33 36 4: 4 8 12 16 20 24 28 32 36 40 44 48 5: 5 10 15 20 25 30 35 40 45 50 55 60 6: 6 12 18 24 30 36 42 48 54 60 66 72 7: 7 14 21 28 35 42 49 56 63 70 77 84 8: 8 16 24 32 40 48 56 64 72 80 88 96 9: 9 18 27 36 45 54 63 72 81 90 99 108 10: 10 20 30 40 50 60 70 80 90 100 110 120 11: 11 22 33 44 55 66 77 88 99 110 121 132 12: 12 24 36 48 60 72 84 96 108 120 132 144
  7. Write a program that prints all prime numbers between 2 and 30. Commit "prime numbers" Example output: 2 3 5 7 11 13 17 19 23 29
  8. Write a guessing game where the user has to guess a secret number that is randomely found by your program (between 1 and 100). After every guess the program tells the user whether their number was too large or too small. At the end the number of tries (8) needed should be printed. I counts only as one try if they input the same number multiple times consecutively. Example input: 90 Example output: too large trial 1/8 Example input: 20 Example output: too small trial 2/8 Example input: 50 Example output: too large trial 3/8 Example input: 40 Example output: too small trial 4/8 Example input: 45 Example output: Correct with 5 trials!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published