Modern Application Development II, Quiz 2
Consider the following JavaScript code.
function promiseBuilder(t) { return new Promise((res, rej) => { setTimeout(() => { const count = Math.floor(t / 1000) if (count > 3) { res(count) } else { rej(count * 2) } }, t) })}
async function getData() { let data1 = null, data2 = null try { data1 = await promiseBuilder(5000) } catch (e) { data1 = 30 } try { data2 = await promiseBuilder(2000) } catch (e) { data2 = 40 } return data1 + data2}
getData().then( (res) => { console.log(8 * res) }, (err) => { console.log(6 * err) })What will be logged on to the console?
Consider the following JavaScript code. function promiseBuilder(t) { return new Promise((res, rej) => { setTimeout(() => { const count = Math.floor(t / 1000) if (count > 3) { res(count) } else { rej(count * 2) } }, t) }) } async function getData() { let data1 = null, data2 = null try { data1 = await promiseBuilder(5000) } catch (e) { data1 = 30 } try { data2 = await promiseBuilder(2000) } catch (e) { data2 = 40 } return data1 + data2 } getData().then( (res) => { console.log(8 * res) }, (err) => { console.log(6 * err) } ) What will be logged on to the console? Consider the Vue application with markup index.html and JavaScript app.js index.html <body> <div id="app"></div> </body> app.js const NavBar = { template: `<ul> <li> Home </li> <slot><li>Bowling Average</li></slot> </ul>`, } const Batsman = { template: `<NavBar><li>Batting Average</li><li>Strike Rate</li></NavBar>`, components: { NavBar, }, } new Vue({ el: '#app', template: `<Batsman />`, components: { Batsman, }, }) Suppose the application is running on “http://localhost:8080” . What will be rendered by the browser? Consider the following Vue app with markup index.html and JavaScript app.js. index.html <body> <div id="app"></div> </body> app.js const Dashboard = { template: `<div> This is dashboard for {{user.name}} </div>`, props: ['id'], data() { return { users: [ { id: 1, name: 'User1' }, { id: 2, name: 'User2' }, { id: 3, name: 'User3' }, ], } }, computed: { user() { const user = this.users.find((user) => user.id == this.id) if (user) { return user } else { return this.users[2] } }, }, } const router = new VueRouter({ routes: [{ path: '/dashboard/:id', component: Dashboard, props: true }], }) new Vue({ el: '#app', template: `<router-view />`, router, }) Suppose the application is running on “http://localhost:8080” . What will be rendered inside the router-view component of root component for the URL “http://127.0.0.1:8080/#/dashboard/8” ?