because Cambridge International is stuck in the past. They still use var for declaring instead of let. They mark to the mark scheme. It's 2021 and they don't even use ES6 lol.
What happens if you, sensibly, replace innerHTML by innerText?
That aside, based on the snipped you posted, the closest thing I can come up with, that actually preserved the behavior in all cases, is
document.getElementById("percent").innerHTML = Math.round(count*12.5)+"%";
const display = document.getElementById("display");
switch(count) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
display.src = "Bar" + count + ".png";
break;
case 8: // deviating capitalization, but why??
display.src = "bar8.png";
break;
default:
// Not clear from the screenshot.
}
that should be fine, in previous past papers I've done with OP the mark schemes didn't really have a problem with things like that. they're just really pedantic about getting SOME stuff in your answer, and what those things are is a mystery when doing the exam. you might think of a much more efficient way of doing it, but if it's not in the mark scheme, bully for you
Because clever isn't always right constructing a name based on a pattern you see and not on spec can cause problems later. This looks more like a making problem than a problem around file name convention.
not sure if you are agreeing or disagreeing, but for adding more imagines, there are often one-offs, or special logic for things. It is rare, and often bad, to just have a bunch of images with some sort of counter on it.
I would say the above had a bad code smell of poor file management if the images are just numbered like that. The only time I've seen numbered really work is when doing a percentage for images. Like Percent75.png. But even in that case, the image has a logic to it, and it is extremely rare 100 images for percentages.
Maybe there is a 'default' case in the switch that you don't handle with your 2 lines solution (count > some specific value). Otherwise getting less marks doesn't make sense at all.
my first thought was a default case too, but the amount of images shouldn't be unknown should it? and if it is unknown they could always set a fallback with onerror
109
u/alexppetrov Sep 14 '21
Why would you loose 3 marks for doing the right thing?
43
u/bugqualia Sep 14 '21
Looks suspiciously like 4chan
13
u/MaxTheMutant Sep 14 '21
Maybe there is a 'default' case in the switch that you don't handle with your 2 lines solution (count > some specific value). Otherwise getting less marks doesn't make sense at all.
6
u/[deleted] Sep 14 '21
Does the question specify that a switch statment should be used?
5
u/Impossible_Average_1 Sep 14 '21
Because case 8 is a special case where you shouldn't round for some reason.
3
u/PewDiePans Sep 14 '21
Ahhh, my eyes burn , please some coffee to cool them !!!!