Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (10 points) Write a program that uses regular expression 1. Replace the word Decimal to Binary 2. find all the numbers in the supplied

image text in transcribed
image text in transcribed
2. (10 points) Write a program that uses regular expression 1. Replace the word "Decimal" to "Binary" 2. find all the numbers in the supplied string. Convert the numbers to binary numbers. Using regular expression replace method to replace the numbers in the string with the converted binary numbers. ( 0b represents a binary number, as example binary number 0b10 is decimal number 2 ) You may perform the conversion in 2 separate steps. (Hint: You may modify the following example from the textbook: let s= "the cia and fbim; console.log(s.replace(/ b(fbicia)\b/g, str= str.toUpperCase())); // the CIA and FBI Find all the numbers. Use toString(2) to convert the decimal number to binary.) The string: "In Decimal, 2 plus 4 is 6 and 12 minus 7 is 5 " The converted string: "In Binary, 0b10 plus 0b100 is 0b110 and 0b1100 minus 0b111 is 0b101" 3. (10 points) Use the JavaScript playground website introduced in the class video/PPT (Is (forked) - StackBlitz) to implement a module. The JavaScript module file (could be called larger.js) has a function that finds the larger of two numbers. The module then exports the function. Index.js imports the function from larger.js. 2 random whole numbers are then passed to the imported function. Finally, the larger number is then displayed in the console. As example, if 5 and 8 are used, the console will display " 8 is the larger number" 0 point assigned if not using module to export and import the function that finds the larger number. Submit your js files and a screenshot of the index.js file content with the console screen displaying the output

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

3 The distinction between microeconomics and macroeconomics.

Answered: 1 week ago

Question

2 The role of economic theory in economics.

Answered: 1 week ago