Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. ex 1
  2. a:
  3. daca variabila nu exista
  4. //
  5. if (typeof variable == 'undefined') {
  6. console.log("variabila nu este definita");
  7. }
  8. else
  9. //
  10.  
  11. b:
  12. //
  13. if (typeof testvar == 'undefined')
  14. {
  15. console.log("variabila nu este definita");
  16. }
  17.  
  18. else {
  19. if (typeof testvar ==='string' && testvar!="")
  20. {console.log("Variabila este sir si este diferit de \"\" ");
  21. }
  22.  
  23. }
  24. //
  25.  
  26.  
  27. ex2
  28. //
  29. propozitie = "Azi avem de făcut piața. Aceasta este lista de fructe de cumpărat: cirese,portocale, mere, banane."
  30. var start=propozitie.indexOf(':');
  31. var end=propozitie.indexOf('.',start+1);
  32. propozitie.replace('cirese','caise');
  33. propozitie.replace('mere','pere');
  34. var lista=propozitie.substring(start+1,end);
  35. var fructe=lista.split(',');
  36. //
  37.  
  38. ex3
  39.  
  40.  
  41. //
  42.  
  43. var Dinozauri=["T-Rex","Stegozaur","Alozaur","Velociraptor","Pterodadon"];
  44. for (i=0;i<Dinozauri.length;i++){
  45.  
  46. if(Dinozauri[i]=="Alozaur") console.log("Pozitia lui Alozaur este "+i);
  47.  
  48. if(Dinozauri[i]=="Apatozaur") console.log("Pozitia lui apatozaur este "+i);
  49. }
  50. //
  51.  
  52. ex 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement