Fix rest parameter mis-match

I think you intended to have working code 😄
This commit is contained in:
Skubie Doo 2017-03-26 15:55:52 -04:00 committed by GitHub
parent a22c2a3d29
commit b8d1e690f0

View file

@ -53,10 +53,11 @@ Here the first two arguments go into variables and the rest goes to `titles` arr
function showName(firstName, lastName, ...titles) { function showName(firstName, lastName, ...titles) {
alert( firstName + ' ' + lastName ); // Julius Caesar alert( firstName + ' ' + lastName ); // Julius Caesar
// the rest = ["Consul", "Imperator"] // the rest go into titles array
alert( rest[0] ); // Consul // i.e. titles = ["Consul", "Imperator"]
alert( rest[1] ); // Imperator alert( titles[0] ); // Consul
alert( rest.length ); // 2 alert( titles[1] ); // Imperator
alert( titles.length ); // 2
} }
showName("Julius", "Caesar", "Consul", "Imperator"); showName("Julius", "Caesar", "Consul", "Imperator");