What you want to do is something like this:
-
Get the user’s numbers and save them, prefably in an array.
-
Loop through all the numbers and check if the number is N.
-
If so, alert the user.
-
Sort the array, alert the user.
Attempt to code:
// All the user's numbers
var UserNumbers = [15, 10, 11, 12, 13];
//The value to search for
var N = 12;
//Loop through the values
for(var i = 0; i < UserNumbers.Length; i++){
if(UserNumbers[i] == N){
//The number matches
alert("You reached the end of the sequence";
}
}
// I am not sure what you mean with cresent order so that you'll have to solve for yourself.
//Sort the UserNumbers here
//Store the message to show the user
var message = "";
//Loop through the values - now in correct order and save them to the message
for(var i = 0; i < UserNumbers.Length; i++){
//Add to the message
message += UserNumbers[i] + " ";
}
//Show the message - all the containing numbers
alert(message);
Although this is an helpful community I am pretty certain that we’re not made out of teachers here to teach you how to code. Since this sounds to be an homework rather than a real life scenario, talk with your teacher or classmates. Good luck and next time, try to do some research before posting a question – there are plenty of tutorials for beginners out there.
solved Javascript coding