MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / displayOutlineDiamond

Function displayOutlineDiamond

javascript_games/diamonds.js:29–47  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

27
28
29function displayOutlineDiamond(size) {
30 // Display the top half of the diamond:
31 for (let i = 0; i < size; i++) {
32 process.stdout.write(' '.repeat(size - i - 1)); // Left side space.
33 process.stdout.write('/'); // Left side of diamond.
34 process.stdout.write(' '.repeat(i * 2)); // Interior of diamond.
35 process.stdout.write('\\'); // Right side of diamond.
36 console.log();
37 }
38
39 // Display the bottom half of the diamond:
40 for (let i = 0; i < size; i++) {
41 process.stdout.write(' '.repeat(i)); // Left side space.
42 process.stdout.write('\\'); // Left side of diamond.
43 process.stdout.write(' '.repeat((size - i - 1) * 2)); // Interior of diamond.
44 process.stdout.write('/'); // Right side of diamond.
45 console.log();
46 }
47}
48
49function displayFilledDiamond(size) {
50 // Display the top half of the diamond:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected