SHARE
TWEET

Untitled

K_Tomi Oct 17th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.clear();
  2. const rl = require('readline-sync');
  3.  
  4. const randNumbers = [];
  5. var howManyNumbers = rl.question(
  6.   'Add meg, hány random szám legyen a tömbben: '
  7. );
  8. for (let i = 0; i < howManyNumbers; i++) {
  9.   const item = Math.floor(Math.random() * 100 + 1);
  10.   randNumbers.push(item);
  11. }
  12. console.log(`Random ${howManyNumbers} db szám 1-100 között: ` + randNumbers);
  13. console.log();
  14. var howManyToCount = 0;
  15. while (howManyToCount === 0) {
  16.   howManyToCount = rl.question('Ebből hányat állítsak növekvő sorba: ');
  17.   if (randNumbers.length < howManyToCount || howManyToCount <= 0) {
  18.     console.clear();
  19.     console.log(
  20.       `A tömbben ${randNumbers.length} db szám van! Másik számot kérek!`
  21.     );
  22.     console.log();
  23.     console.log(randNumbers);
  24.     howManyToCount = 0;
  25.   }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top