Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function zbior(){
- var liczby = [];
- for(var i =0;i<arguments.length;i++){
- liczby[i]=arguments[i];
- }
- this.sprawdz = function(x){
- p=false;
- for(var i=0;i<liczby.length;i++){
- if(x==liczby[i]){p=true;}
- }
- return p;
- }
- this.dodaj = function(x){
- x=parseInt(x);
- if(this.sprawdz(x)==false){liczby.push(x);}
- }
- this.wypisz = function (){
- for(var i =0;i<liczby.length;i++){
- console.log(liczby[i]);
- }
- }
- this.usun = function(x){
- x=parseInt(x);
- for(var i=0;i<liczby.length;i++){
- if(x==liczby[i]){
- liczby.splice(i,1);
- }
- }
- }
- }
- var zbior1 = new zbior(1,2,6);
- zbior1.dodaj(23.13443234);
- zbior1.dodaj(23);
- zbior1.dodaj(23.1321231231241521);
- zbior1.dodaj(24.5);
- zbior1.dodaj(26.12);
- zbior1.dodaj(2);
- zbior1.wypisz();
- console.log(zbior1.sprawdz(23));
- zbior1.usun(23);
- zbior1.wypisz();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement