Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using PPM called demo-254-8x6-no-comment.ppm which is stated below: P3 8 6 255 128 58 90202 48 6538 2 193202 33 97150 72 94 148 129

Using PPM called "demo-254-8x6-no-comment.ppm" which is stated below:

P3

8 6

255

128 58 90202 48 6538 2 193202 33 97150 72 94

148 129 101150 111 197218 160 16582 128 158191 122 34

75 225 187174 64 12986 140 1653 142 190184 246 73

247 94 152253 118 36182 90 7111 249 11389 203 65

242 2 15274 220 67244 211 3762 88 153124 187 237

173 136 167172 89 225104 113 99213 68 26157 23 194

140 175 201180 170 16841 88 249186 194 129132 152 27

82 243 21224 79 99206 244 11123 119 9091 75 178

132 223 25167 5 90163 230 10042 69 160141 43 136

113 54 20483 247 4880 124 2

Generate a function getWidth(arr) that takes a single argument: a 1D array containing the

contents of a PPM file. The array returned from openPPM(path) would be used passed into

this function when calling it.

The functions returns the width of the image. Recall which value in the array contains the

width value.

function getWidth(arr) {

// Your code here...

}

To test your function, you will call your function in the index.js file:

let ppmArray = ppm.openPPM('./demo-254-8x6-no-comment.ppm');

let width = ppm.getWidth(ppmArray);

console.log({width});

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions