Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. var SpecialConsole=(function(){
  2. var arr=[];
  3. function SpecialConsole(){
  4.  
  5. }
  6. SpecialConsole.prototype.writeLine=function (){
  7. if(arguments.length===1){
  8. return console.log("Message: "+arguments[0]);
  9. }else if(arguments.length>1){
  10.  
  11. for (var i = 0; i < arguments.length; i++) {
  12. arr.push(arguments[i]);
  13. }
  14. if(arr.length%2===0){
  15. for (var j = 0; j < arr.length; j++) {
  16. if(arr[j]==='{'+ j.toString()+'}'){
  17. console.log(arguments[(arr.length/2)+j]);
  18. }else{
  19. break;
  20. }
  21. }
  22. }else{
  23. console.log('error')
  24. }
  25.  
  26. }
  27. };
  28.  
  29. return SpecialConsole;
  30. })();
  31.  
  32. var specialConsole= new SpecialConsole();
  33. specialConsole.writeLine('Hello special console!');
  34. specialConsole.writeLine('{0}','{1}','pesho','nasko');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement