Advertisement
Tyrsdei

Untitled

Jul 10th, 2018
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var dave, jason, nick, get;
  2.  
  3. get = prompt('Input your Name', 'Name Here')
  4.  
  5.  
  6. var Person = function (name, birthYear, job) {
  7.     this.name = name;
  8.     this.birthYear = birthYear;
  9.     this.job = job;
  10. };
  11.  
  12. dave = new Person('Dave', 1976, 'Carnie');
  13. jason = new Person('Jason', 1987, 'Novice');
  14. nick = new Person('Nick', 1993, 'Cable-tech');
  15.  
  16.  
  17. function printObj(object) {
  18.     var output = '';
  19.     for (var property in object) {
  20.         output += property + ': ' + object[property] + '\n';
  21.     }
  22.     alert(output);
  23. }
  24.  
  25. if (get.toLowerCase === 'dave'.toLowerCase) {
  26.     printObj(dave);
  27. } else if (get.toLowerCase === 'jason'.toLowerCase) {
  28.     printObj(jason);
  29. } else if (get.toLowerCase === 'nick'.toLowerCase) {
  30.     printObj(nick);
  31. } else {
  32.     alert('Not a defined object')
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement