Advertisement
Ezvalt

Untitled

Feb 8th, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 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. var x = 'kek@lol.ro';
  21.  
  22.  
  23. var gasit = false;
  24. for(var i=0; i<emailuri.length; i++){
  25. // console.log(emailuri[i] + ' vs ' + x);
  26. if(emailuri[i] == x){
  27. // console.log('DA');
  28. gasit = true;
  29. }else{
  30. // console.log('NU');
  31. }
  32. }
  33.  
  34. if(gasit){
  35. console.log('DA');
  36. }else{
  37. console.log('NU');
  38. }
  39.  
  40. // TODO: exact aceeasi chestie si pentru note
  41. var notaCautata = 5;
  42. var gasita = false;
  43.  
  44. for(var i=0; i<note.length; i++) {
  45. if(note[i] == notaCautata)
  46. gasita = true;
  47. }
  48. if(gasita) {
  49. console.log('exista');
  50. } else
  51. {
  52. console.log('nu exista');
  53. };
  54.  
  55. // 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?
  56.  
  57.  
  58. </script>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement