Help with while loop in java script

Hi there,
I am new to java. I am wondering if I could receive some guidance from anybody regarding the following project:
Create a program that takes inputs from the user and completes the following tasks. The program

  1. Will take two numbers from the user: start and stop. Assume that start will be greater than stop.
  2. Using a while loop, print all the numbers from start up to stop, including start and stop.
  3. Using a while loop, print all the numbers from stop down to start, including stop and start.
  4. Using a while loop, print all the odd numbers from start up to stop, including start and stop.
  5. Using a while loop, print all the numbers that are divisible by 3 but not divisible by 5, from start up to stop, including start and stop.
  6. Using a while loop, sum up all the numbers from start to stop. Show the result of the addition.
  7. Using a while loop, sum up all the odd numbers from start to stop. Show the result.
  8. Using a while loop, sum up all the even numbers from start to stop. Show the result.

Is this a homework problem? You should try to debunk it by yourself, if you want to get better. All of the things you listed is very similar to each other.

Loops is a very basic thing, read this, it’s explained there really well https://www.w3schools.com/js/js_loop_for.asp

loops r not something u have doubt in, they r really easy. Not gonna take a class here still:
there r 3 kinds of loops :-

  1. for = a loop that can initiate, test and upgrade values within the loop itself.
    2.while =in here u only have to test the condition
  2. do-while = this is the only loop that is sure to run at least ones.

rest can be learnt from freecodecamp itelf

Firstly, welcome to the forums.

Java and JavaScript are two different languages, careful there, you mention one of the two in the title and the other in the body of your post.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. If you are referring to JavaScript language (and not Java), some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

1 Like