Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Hospital(name, diagnosis, days) {
- this.name = name;
- this.diagnosis = diagnosis;
- this.days = days;
- }
- Hospital.prototype.toString = function () {
- return this.name + " " + this.diagnosis + " " + this.days
- }
- let n = Number(prompt('n'))
- let patients = []
- for (let i = 0; i < n; i++) {
- let name = prompt('name')
- let diagnosis = prompt('diagnosis')
- let days = Number(prompt('days'))
- let patient = new Hospital(name, diagnosis, days)
- patients.push(patient)
- }
- for (let i = 0; i < n; i++) {
- alert(patients[i])
- }
- let longestIndex = 0
- for (let i = 0; i < n; i++) {
- if(patients[i].days > patients[longestIndex].days) {
- longestIndex = i
- }
- }
- alert(patients[longestIndex])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement