Advertisement
Guest User

Untitled

a guest
Feb 8th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <html>
  2. <head></head>
  3. <body>
  4. <h2>Exemplu cautare</h2>
  5. <script>
  6.  
  7. function test(){
  8. console.log('acesta este un test');
  9. }
  10. test();
  11. test();
  12.  
  13. var emailuri = ['ion@gmail.com', 'iion@yahoo.com', 'ion@hotmail.uk', 'kek@lol.ro', 'alina@yahoo.com'];
  14.  
  15. var note = [10, 3, 9, 8, 9, 7, 10, 6];
  16.  
  17. console.log('emailurile sunt: ', emailuri);
  18. console.log('notele sunt: ', note);
  19.  
  20. if(emailuri.indexOf('kek@lol.ro')){
  21. console.log('DA');
  22. }else{
  23. console.log('NU');
  24. }
  25.  
  26. // TODO: exact aceeasi chestie si pentru note
  27. var notaCautata = 5;
  28. var gasita = false;
  29.  
  30. for(var i=0; i<note.length; i++) {
  31. if(note[i] == notaCautata)
  32. gasita = true;
  33. }
  34. if(gasita) {
  35. console.log('exista');
  36. } else
  37. {
  38. console.log('nu exista');
  39. };
  40.  
  41. // TODO: cum am putea simplifica codul a.i. sa nu facem un for si un if de fiecare data cand cautam ceva intr-un array?
  42.  
  43.  
  44. </script>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement