Question 2
Consider the following Vue application with javascript file “app.js” and markup file “index.html”.
app.js:
const Teams = { template: `<ol><li v-for='team inteams'>{{team.name}}</li></ol>`, data() { return { teams: [ { name: 'India', points: 827 }, { name: 'Australia', points: 820 }, ], } },}const Rankings = { template: `<ol><li v-for='team in sortedTeams'>{{team.name}}</li></ol>`, data() { return Teams.data() }, computed: { sortedTeams() { return this.teams.sort((team1, team2) => { return team1.points - team2.points // Statement 1 }) }, },}
const router = new VueRouter({ routes: [ { path: '/', component: Teams }, { path: '/ranking', component: Rankings }, ],})
new Vue({ el: '#app', template: `<div> <router-view /> </div>`, router,})index.html:
<div id="app"></div>Suppose the application is running on “http://localhost:8080”. If the developer wants to display the teams in descending order with respect to the points of team, for the URL “http://localhost:8080/#/ranking”. What should be the value of return statement in “sortedTeams” computed property (Marked by statement1)?
team1.points - team2.points
team2.points - team1.points
team1 > team2
team2 < team1