The code below produces a 5 x 10 box of question marks. Convert the code into a function called drawBox() that takes three parameters: 1. numRows - The number of rows for the box. 2. numCols - The number of columns for the box. 3. boxChar - The character to use to create the box. If no argument is supplied, use "X". Ex: drawBox (5, 4, "!") and drawBox (2, 6) should display the boxes pictured below. !!!! !!!! !!!! !!!! !!!! XXXXXX XXXXXX

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 12SA: 12. What is the output of the following program? (2, 3, 6, 8) #include <iostream> #include...
icon
Related questions
Question
100%

I am having trouble with writing a function in javascript.  The specific exercise is participation activity 6.6.3 of Zybook.  I am not sure what I am doing wrong.  Can you help?

PARTICIPATION
6.6.3: Function practice.
АCTIVITY
The code below produces a 5 x 10 box of question marks. Convert the code into a function
called drawBox() that takes three parameters:
1. numRows - The number of rows for the box.
2. numCols - The number of columns for the box.
3. boxChar - The character to use to create the box. If no argument is supplied, use "X".
Ex: drawBox (5, 4, "!") and drawBox(2, 6) should display the boxes pictured below.
!!!!
!!!!
!!!!
!!!!
!!!!
XXXXXX
XXXXXX
1 / Convert into a drawBox function
2 for (var r = 0; r < 5; r++) {
var line = "":
for (var c = 0; c < 10; C++) {
line += "?";
}
console.log(1ine);
3
4
6.
7
8 }
Transcribed Image Text:PARTICIPATION 6.6.3: Function practice. АCTIVITY The code below produces a 5 x 10 box of question marks. Convert the code into a function called drawBox() that takes three parameters: 1. numRows - The number of rows for the box. 2. numCols - The number of columns for the box. 3. boxChar - The character to use to create the box. If no argument is supplied, use "X". Ex: drawBox (5, 4, "!") and drawBox(2, 6) should display the boxes pictured below. !!!! !!!! !!!! !!!! !!!! XXXXXX XXXXXX 1 / Convert into a drawBox function 2 for (var r = 0; r < 5; r++) { var line = "": for (var c = 0; c < 10; C++) { line += "?"; } console.log(1ine); 3 4 6. 7 8 }
1 // Convert into a drawBox function
2 function drawBox (numRows, numCols, boxChar) {
3 for (var r = 0; r < 5; r++) {
var line = "!";
for (var c = 0; c < 3; C++) {
line += "!";
}
console.log(1ine);
4
6.
7
9 }
10 }
11 drawBox (5, 4, "!");
12 {
13 for (varr = 0; r < 2; r++) {
var line = "X";
for (var c = 0; c < 6; C++) {
line += "X";
}
console.log(line);
14
15
16
17
18
19 }
20 }
21 drawBox (2, 6, "Х");
Transcribed Image Text:1 // Convert into a drawBox function 2 function drawBox (numRows, numCols, boxChar) { 3 for (var r = 0; r < 5; r++) { var line = "!"; for (var c = 0; c < 3; C++) { line += "!"; } console.log(1ine); 4 6. 7 9 } 10 } 11 drawBox (5, 4, "!"); 12 { 13 for (varr = 0; r < 2; r++) { var line = "X"; for (var c = 0; c < 6; C++) { line += "X"; } console.log(line); 14 15 16 17 18 19 } 20 } 21 drawBox (2, 6, "Х");
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning