Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I got a really confused about javascript sometimes! how to answer this question !? this is a file of javascript and these are the questions

I got a really confused about javascript sometimes! how to answer this question !?

this is a file of javascript and these are the questions :

  1. Modules - rewrite the code so that it uses a new module (view.js) for the view function and imports that function into the main.js file.
  2. Handlebars templates - rewrite the code so that it uses Handlebars templates to generate the HTML to insert into the page. I've already included the handlebars library into the index.html page for you.

  1. onclick handler for the button with id "action".Label the button "S1 Units" and when it is clicked, update the display to only show the S1 units from the list.
  2. Add further buttons (you can change the HTML if you wish or do it from Javascript) to display the S2 unit

// Here's the units data again

let all_units = [

{

'code': 'COMP2110',

'title': 'Web Technology',

'offering': 'S1'

},

{

'code': 'COMP2010',

'title': 'Algorithms and Data Structures',

'offering': 'S1'

},

{

'code': 'COMP2150',

'title': 'Game Design',

'offering': 'S1'

},

{

'code': 'COMP2320',

'title': 'Offensive Security',

'offering': 'S1'

},

{

'code': 'COMP2200',

'title': 'Data Science',

'offering': 'S2'

},

{

'code': 'COMP2250',

'title': 'Data Communications',

'offering': 'S2'

},

{

'code': 'COMP2300',

'title': 'Applied Cryptography',

'offering': 'S2'

},

{

'code': 'COMP2000',

'title': 'Object-Oriented Programming Practices',

'offering': 'S2'

},

{

'code': 'COMP2050',

'title': 'Software Engineering',

'offering': 'S2'

},

{

'code': 'COMP2100',

'title': 'Systems Programming',

'offering': 'S2'

}

];

/*

* Display a list of units as a table in the element with the

* given id.

*/

function unit_table(id, units) {

let target = document.getElementById(id);

let table = "

"

table += "

";

for (let i=0; i

table += "

";

}

table += "

CodeTitleOffering
" + units[i].code +

"

" + units[i].title +

"

" + units[i].offering + "
"

target.innerHTML = table;

}

window.onload = function() {

this.unit_table("content", all_units);

}

To test your skills do the below :

  1. Copy the array of units (just the array, not the variable name) into a new file with a .json extension
  2. Convert your application to use the fetch API to request the JSON file and update the page when it arrives.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions