Advertisement
tsekotsolov

Untitled

Mar 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ReservationCode {
  2.  
  3.   constructor(name, rc) {
  4.     this.name = name;
  5.     this.rc = rc;
  6.   }
  7.  
  8.   getCode() {
  9.     if (this.rc.length % 2 === 0) {// i do not assume i check
  10.  
  11.       let result='';
  12.       for (let i = 0; i < this.rc.length; i += 2) {
  13.         result += this.rc[i] + this.rc[i + 1] + '-'
  14.       }
  15.      return result.substring(result.length-1,0);
  16.     }
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement