pythontutor-dev / pythontutor

10 stars 4 forks source link

mysterious typescript errors #50

Open pgbovine opened 5 years ago

pgbovine commented 5 years ago

(from server error logs; some work in javascript, don't have energy to minimize/debug)

 `<h1>Attention!</h1>
<p>Votre abonnement va prochainement se terminer.
Il ne vous reste que ${joursAbonnement} jours <p>`
const checker = function(input) {
    const reverse = function(str) {
        return str.split('').reverse().join('');
    };

    const validator = {
        str1 : 'iscor',
        str2 : reverse('tcer'),
        str3 : 'isth',
        validate(attempt) {
            return attempt === (validator.str3 + validator.str1 + validator.str2);
        },
    };

    return validator.validate(input);
};
const x = 5;

function p() {
  return m()
}

function m() {
  try {
    return x;
  } finally {
    console.log('hi');
  }
}

const z = {
  p,
  m,
}

m();
function Devs(name,age, job){
    this.name = name;
    this.age = age;
    this.job = job;
    this.presentation  = function(style, timeOfDay){
        if(style === 'formal'){
            console.log(`Good ${timeOfDay}, Ladies and Gentlemen. I am ${this.name}
            and I do ${this.job} for a living.
            `)
        }else if(style === 'casual'){
            console.log(`Whats up guys ${timeOfDay}. You know me...I  am ${this.name}
            and I do ${this.job} for a living.`);
        }else{
            console.log(`Hi there , ${timeOfDay} Ladies and Gentlemen.`)
        }
    };
}
Devs.prototype.org = 'LinkedIn';
Devs.prototype.presentation  =  function(style, timeOfDay){
    if(style === 'formal'){
        console.log(`Good ${timeOfDay}, Ladies and Gentlemen. I am ${this.name}
            and I do ${this.job} for a living.
            `)
    }else if(style === 'casual'){
        console.log(`Whats up guys ${timeOfDay}. You know me...I  am ${this.name}
            and I do ${this.job} for a living.`);
    }else{
        console.log(`Hi there , ${timeOfDay} Ladies and Gentlemen.`)
    }

};
let John  = new Devs('John', 47, "Architect");
let Emily  = new Devs('Emily', 37, "UXDesigner");
console.log(John.presentation === Emily.presentation);
//Emily.presentation  = function(){};
John.presentation('casual','Morning');
Emily.presentation('formal','Evening');
console.log(Emily.org);
console.log(John.org);
function padLeft(value: string, padding: any) {
    if (typeof padding === "number") {
        return Array(padding + 1).join(" ") + value;
    }
    if (typeof padding === "string") {
        return padding + value;
    }
    throw new Error(`Expected string or number, got '${padding}'.`);
}