Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head></head>
- <body>
- <h2>Exemplu cautare</h2>
- <script>
- function test(){
- console.log('acesta este un test');
- }
- test();
- test();
- var emailuri = ['ion@gmail.com', 'iion@yahoo.com', 'ion@hotmail.uk', 'kek@lol.ro', 'alina@yahoo.com'];
- var note = [10, 3, 9, 8, 9, 7, 10, 6];
- console.log('emailurile sunt: ', emailuri);
- console.log('notele sunt: ', note);
- var x = 'kek@lol.ro';
- var gasit = false;
- for(var i=0; i<emailuri.length; i++){
- // console.log(emailuri[i] + ' vs ' + x);
- if(emailuri[i] == x){
- // console.log('DA');
- gasit = true;
- }else{
- // console.log('NU');
- }
- }
- if(gasit){
- console.log('DA');
- }else{
- console.log('NU');
- }
- // TODO: exact aceeasi chestie si pentru note
- var notaCautata = 5;
- var gasita = false;
- for(var i=0; i<note.length; i++) {
- if(note[i] == notaCautata)
- gasita = true;
- }
- if(gasita) {
- console.log('exista');
- } else
- {
- console.log('nu exista');
- };
- // 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?
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement