Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!