blueBelt.html 791 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Blue Belt</title>
  6. </head>
  7. <body>
  8. <script>
  9. function pass(right,wrong){
  10. let login=prompt('','');
  11. let pass=prompt('','');
  12. if(this.logIn==login && this.password==pass){
  13. right();
  14. }
  15. else{
  16. wrong();
  17. }
  18. }
  19. let obj={
  20. logIn:'Ivan',
  21. password:'hello',
  22. right:function(){
  23. let div=document.createElement('div');
  24. div.style.backgroundColor='green';
  25. div.innerHTML='Congratulations !';
  26. document.body.append(div);
  27. },
  28. wrong:function(){
  29. let div=document.createElement('div');
  30. div.style.backgroundColor='red';
  31. div.innerHTML='Something Wrong !';
  32. document.body.append(div);
  33. }
  34. };
  35. let g=pass.bind(obj);
  36. g(()=>obj.right(),()=>obj.wrong());
  37. </script>
  38. </body>
  39. </html>