Number guessing game. Common issue with test passing

Hello guys!

I’ve made the other exercises from RB course and I have got only 1 left. And only this one I can’t finish by myself.

The output is the same but project is not completed.
Usually I have problems with 2 tasks:

  1. Welcome back, ! You have played <games_played> games, and your best game took <best_game> guesses.
  2. You guessed it in <number_of_guesses> tries. The secret number was <secret_number>. Nice job!

But sometimes when I change smth in my code it ruins the others starting “Enter your username:”.

I checked a lot of topics here about the issue and couldn’t find any answer that will help me.

Please help me to find the mistake. I’m trying to find it a couple of days for hours.

Here is .sh:

#!/bin/bash

PSQL="psql --username=freecodecamp --dbname=number_guess -t --no-align -c"

echo "Enter your username:"
read USERNAME

USER_ID=$($PSQL "SELECT user_id FROM users WHERE username='$USERNAME'")

if [[ -z $USER_ID ]]
then
  echo "Welcome, $USERNAME! It looks like this is your first time here."
  INSERT_USERNAME=$($PSQL "INSERT INTO users(username) VALUES('$USERNAME')")
else
  GAMES_PLAYED=$($PSQL "SELECT games_played FROM users WHERE user_id=$USER_ID")
  BEST_GAME=$($PSQL "SELECT best_game FROM users WHERE user_id=$USER_ID")
  echo "Welcome back, $USERNAME! You have played $GAMES_PLAYED games, and your best game took $BEST_GAME guesses."
fi

# guessing game

SECRET_NUMBER=$(( $RANDOM % 1000 + 1 ))
#echo $SECRET_NUMBER


GUESS() {
  if [[ $1 ]]
  then
    echo -e "\n$1"
  fi
  
  echo "Guess the secret number between 1 and 1000:"
  read GUESSING_NUMBER

  NUMBER_OF_GUESSES=0
  while true
  do
    if [[ ! $GUESSING_NUMBER =~ ^[0-9]+$ ]]
    then
      echo -e "\nThat is not an integer, guess again:"
      read GUESSING_NUMBER
      echo $GUESSING_NUMBER
    else
      if [[ $GUESSING_NUMBER -gt 1000 || $GUESSING_NUMBER -eq 0 ]]
      then
        echo "I told you that the number should be between 1 and 1000. Restart the game."
        exit
      fi
      if [[ $GUESSING_NUMBER -eq 1000 && $GUESSING_NUMBER -ne $SECRET_NUMBER ]]
      then
        echo -e "\nIt's lower than that, guess again:"
        NUMBER_OF_GUESSES=$((NUMBER_OF_GUESSES+1))
        echo $NUMBER_OF_GUESSES
        read GUESSING_NUMBER
        echo $GUESSING_NUMBER
        continue
      fi
      if [[ $GUESSING_NUMBER -gt $SECRET_NUMBER ]]
      then
        echo -e "\nIt's lower than that, guess again:"
        NUMBER_OF_GUESSES=$((NUMBER_OF_GUESSES+1))
        echo $NUMBER_OF_GUESSES
        read GUESSING_NUMBER
        echo $GUESSING_NUMBER
        continue
      fi
      if [[ $GUESSING_NUMBER -lt $SECRET_NUMBER ]]
      then
        echo -e "\nIt's higher than that, guess again:"
        NUMBER_OF_GUESSES=$((NUMBER_OF_GUESSES+1))
        echo $NUMBER_OF_GUESSES
        read GUESSING_NUMBER
        echo $GUESSING_NUMBER
      fi
      if [ $GUESSING_NUMBER -eq $SECRET_NUMBER ]
      then
        NUMBER_OF_GUESSES=$((NUMBER_OF_GUESSES+1))
        echo $NUMBER_OF_GUESSES
        echo -e "\nYou guessed it in $NUMBER_OF_GUESSES tries. The secret number was $SECRET_NUMBER. Nice job!"
        break
      fi
    fi
  done

# insert values

GAMES_PLAYED=$($PSQL "SELECT games_played FROM users WHERE username='$USERNAME'")
if [[ -z $GAMES_PLAYED ]]
then
  GAMES_PLAYED=1
else
  GAMES_PLAYED=$((GAMES_PLAYED+1))
fi
UPDATE_GAMES_PLAYED=$($PSQL "UPDATE users SET games_played=$GAMES_PLAYED WHERE username='$USERNAME'")

BEST_GAME=$($PSQL "SELECT best_game FROM users WHERE username='$USERNAME'")
if [[ -z $BEST_GAME ]]
then
  BEST_GAME=$NUMBER_OF_GUESSES
  UPDATE_BEST_GAME=$($PSQL "UPDATE users SET best_game=$BEST_GAME WHERE username='$USERNAME'")
else
  if [[ $BEST_GAME > $NUMBER_OF_GUESSES ]]
  then
    BEST_GAME=$NUMBER_OF_GUESSES
    UPDATE_BEST_GAME=$($PSQL "UPDATE users SET best_game=$BEST_GAME WHERE username='$USERNAME'")
  fi
fi

}

GUESS

Dump

--
-- PostgreSQL database dump
--

-- Dumped from database version 12.9 (Ubuntu 12.9-2.pgdg20.04+1)
-- Dumped by pg_dump version 12.9 (Ubuntu 12.9-2.pgdg20.04+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

DROP DATABASE number_guess;
--
-- Name: number_guess; Type: DATABASE; Schema: -; Owner: freecodecamp
--

CREATE DATABASE number_guess WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'C.UTF-8';


ALTER DATABASE number_guess OWNER TO freecodecamp;

\connect number_guess

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: users; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.users (
    user_id integer NOT NULL,
    username character varying(22) NOT NULL,
    games_played integer,
    best_game integer
);


ALTER TABLE public.users OWNER TO freecodecamp;

--
-- Name: users_user_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.users_user_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.users_user_id_seq OWNER TO freecodecamp;

--
-- Name: users_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.users_user_id_seq OWNED BY public.users.user_id;


--
-- Name: users user_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users ALTER COLUMN user_id SET DEFAULT nextval('public.users_user_id_seq'::regclass);


--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

INSERT INTO public.users VALUES (3, 'user_1683567825921', 4, 643);
INSERT INTO public.users VALUES (2, 'user_1683567825922', 8, 119);
INSERT INTO public.users VALUES (5, 'user_1683568012821', 4, 389);
INSERT INTO public.users VALUES (4, 'user_1683568012822', 8, 10);
INSERT INTO public.users VALUES (7, 'user_1683568085065', 4, 137);
INSERT INTO public.users VALUES (6, 'user_1683568085066', 8, 109);
INSERT INTO public.users VALUES (8, 'user_1683620735094', NULL, NULL);
INSERT INTO public.users VALUES (10, 'user_1683620735093', NULL, NULL);
INSERT INTO public.users VALUES (20, 'user_1683621545203', 6, 105);
INSERT INTO public.users VALUES (1, 'Gina', 3, 15);
INSERT INTO public.users VALUES (11, 'user_1683620824527', NULL, NULL);
INSERT INTO public.users VALUES (12, 'user_1683620824526', NULL, NULL);
INSERT INTO public.users VALUES (14, 'user_1683621331185', 2, 894);
INSERT INTO public.users VALUES (23, 'user_1683621801212', 4, 635);
INSERT INTO public.users VALUES (13, 'user_1683621331186', 8, 133);
INSERT INTO public.users VALUES (22, 'user_1683621801213', 8, 195);
INSERT INTO public.users VALUES (17, 'user_1683621406463', 2, 846);
INSERT INTO public.users VALUES (16, 'user_1683621406464', 10, 185);
INSERT INTO public.users VALUES (25, 'user_1683622135005', 2, 837);
INSERT INTO public.users VALUES (19, 'user_1683621445399', 2, 841);
INSERT INTO public.users VALUES (24, 'user_1683622135006', 10, 153);
INSERT INTO public.users VALUES (26, 'Sam', NULL, NULL);
INSERT INTO public.users VALUES (18, 'user_1683621445400', 8, 371);
INSERT INTO public.users VALUES (15, 'Ken', 1, 14);
INSERT INTO public.users VALUES (28, 'user_1683622600067', 4, 447);
INSERT INTO public.users VALUES (21, 'user_1683621545202', 4, 738);
INSERT INTO public.users VALUES (27, 'user_1683622600068', 5, 262);
INSERT INTO public.users VALUES (30, 'user_1683623069108', 4, 733);
INSERT INTO public.users VALUES (29, 'user_1683623069109', 9, 344);
INSERT INTO public.users VALUES (33, 'user_1683623308994', 1, 327);
INSERT INTO public.users VALUES (32, 'user_1683623308995', 4, 490);
INSERT INTO public.users VALUES (31, 'Lo', 1, 11);
INSERT INTO public.users VALUES (34, 'user_1683623626889', NULL, NULL);
INSERT INTO public.users VALUES (35, 'user_1683623626888', NULL, NULL);


--
-- Name: users_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.users_user_id_seq', 35, true);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);


--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_username_key UNIQUE (username);


--
-- PostgreSQL database dump complete
--


I’m having the same problem with different tests that sometimes pass and sometimes don’t. I really liked the resource, it is a very good primer on bash, git and sql. Three things that seemed daunting just a week ago but now seem more approachable. But the tests don’t seem well designed at all. I’ve decided to give up on trying to get the tests to pass because I feel like I’m wasting time that I could use to learn more.
Here my repo,

It does what it needs, but there’s couple details making test incorrectly detecting answer and number of guesses.

Specifically that’s caused by:

  • Exiting script when number is not between 1 and 1000.
  • Printing number of guesses, and number entered after each guess attempt.

My versions doesn’t do either of that and still won’t pass. Would you mind taking a look at the code? I’ll copy it here for your convenience.

#! /bin/bash
secret_number=$[RANDOM % 1000 + 1]
PSQL="psql --username=freecodecamp --dbname=number_guess -t --no-align --csv -q -c"

echo "Enter your username:"
read username
IFS=',' read user_id games_played best_game <<<$($PSQL "SELECT user_id, COUNT(game_id), MIN(guesses) FROM users LEFT JOIN games USING(user_id) GROUP BY user_id HAVING username='$username'")
if [[ $user_id ]]
then
echo "Welcome back, $username! You have played $games_played games, and your best game took $best_game guesses."
else
user_id=$($PSQL "INSERT INTO users(username) VALUES('$username') RETURNING user_id")
echo "Welcome, $username! It looks like this is your first time here."
fi

game(){
echo $1
read guess
((number_of_guesses+=1))
if [[ $guess =~ ^[0-9]+$ ]]
then

if [[ $guess > $secret_number ]]
then
game "It's lower than that, guess again:"
fi
if [[ $guess < $secret_number ]]
then
game "It's higher than that, guess again:"
fi

else
game "That is not an integer, guess again:"
fi
}
game "Guess the secret number between 1 and 1000:"
$($PSQL "INSERT INTO games(user_id, guesses, number) VALUES($user_id, $number_of_guesses, $secret_number)")
echo "You guessed it in $number_of_guesses tries. The secret number was $secret_number. Nice job!"

Thank you :slight_smile:

@lourendotco I don’t mind, but please create new thread for it, including which tests are giving you troubles. Tracking two issues, originating from different causes, in a single thread can get messy.

@sanity Sure. Did it here Number guess game tests randomly not passing. Thanks!

I delete the part with exit and I understood the problem with numbers.

It worked better.
But again the same mistakes.

I tried to redo the code like other with using two tables these time but still random issues after running.

#!/bin/bash

PSQL="psql --username=freecodecamp --dbname=number_guess -t --no-align -c"

echo "Enter your username:"
read USERNAME

USER_ID=$($PSQL "SELECT user_id FROM users WHERE username='$USERNAME'")

if [[ -z $USER_ID ]]
then
  echo "Welcome, $USERNAME! It looks like this is your first time here."
  INSERT_USERNAME=$($PSQL "INSERT INTO users(username) VALUES('$USERNAME')")
  USER_ID=$($PSQL "SELECT user_id FROM users WHERE username='$USERNAME'")
else
  GAMES_PLAYED=$($PSQL "SELECT COUNT(user_id) FROM games WHERE user_id=$USER_ID")
  BEST_GAME=$($PSQL "SELECT MIN(guesses) FROM games WHERE user_id=$USER_ID")
  echo "Welcome back, $USERNAME! You have played $GAMES_PLAYED games, and your best game took $BEST_GAME guesses."
fi

# guessing game

GUESS() {
  SECRET_NUMBER=$(( $RANDOM % 1000 + 1 ))
  NUMBER_OF_GUESSES=0

  echo "Guess the secret number between 1 and 1000:"

  while true
  do
    read GUESSING_NUMBER
    if [[ ! $GUESSING_NUMBER =~ ^[0-9]+$ ]]
    then
      echo -"\nThat is not an integer, guess again:"
    else
      if [[ $GUESSING_NUMBER -gt $SECRET_NUMBER ]]
      then
        NUMBER_OF_GUESSES=$(($NUMBER_OF_GUESSES+1))
        echo "It's lower than that, guess again:"
      fi
      if [[ $GUESSING_NUMBER -lt $SECRET_NUMBER ]]
      then
        NUMBER_OF_GUESSES=$(($NUMBER_OF_GUESSES+1))
        echo "It's higher than that, guess again:"
      fi
      if [ $GUESSING_NUMBER -eq $SECRET_NUMBER ]
      then
        NUMBER_OF_GUESSES=$(($NUMBER_OF_GUESSES+1))
        GAME_RESULT=$($PSQL "INSERT INTO games(guesses, user_id) VALUES($NUMBER_OF_GUESSES, $USER_ID)")
        echo "You guessed it in $NUMBER_OF_GUESSES tries. The secret number was $SECRET_NUMBER. Nice job!"
        break
      fi
    fi
  done

}

GUESS

New dump

--
-- PostgreSQL database dump
--

-- Dumped from database version 12.9 (Ubuntu 12.9-2.pgdg20.04+1)
-- Dumped by pg_dump version 12.9 (Ubuntu 12.9-2.pgdg20.04+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

DROP DATABASE number_guess;
--
-- Name: number_guess; Type: DATABASE; Schema: -; Owner: freecodecamp
--

CREATE DATABASE number_guess WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'C.UTF-8';


ALTER DATABASE number_guess OWNER TO freecodecamp;

\connect number_guess

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: games; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.games (
    game_id integer NOT NULL,
    guesses integer NOT NULL,
    user_id integer
);


ALTER TABLE public.games OWNER TO freecodecamp;

--
-- Name: games_game_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.games_game_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.games_game_id_seq OWNER TO freecodecamp;

--
-- Name: games_game_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.games_game_id_seq OWNED BY public.games.game_id;


--
-- Name: users; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.users (
    user_id integer NOT NULL,
    username character varying(22) NOT NULL
);


ALTER TABLE public.users OWNER TO freecodecamp;

--
-- Name: users_user_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.users_user_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.users_user_id_seq OWNER TO freecodecamp;

--
-- Name: users_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.users_user_id_seq OWNED BY public.users.user_id;


--
-- Name: games game_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.games ALTER COLUMN game_id SET DEFAULT nextval('public.games_game_id_seq'::regclass);


--
-- Name: users user_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users ALTER COLUMN user_id SET DEFAULT nextval('public.users_user_id_seq'::regclass);


--
-- Data for Name: games; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--



--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--



--
-- Name: games_game_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.games_game_id_seq', 399, true);


--
-- Name: users_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.users_user_id_seq', 91, true);


--
-- Name: games games_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.games
    ADD CONSTRAINT games_pkey PRIMARY KEY (game_id);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);


--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_username_key UNIQUE (username);


--
-- Name: games games_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.games
    ADD CONSTRAINT games_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- PostgreSQL database dump complete
--

Should I count a try if it is not an integer? I wrote that it isn't but maybe it should count as well.

All tests are passing for me with your script. Could you check what’s in the CodeRoad (Tests) in the Output tab at the bottom?

Sure but every time it is different:

FAILED TEST LOG
  ✘ SUBTASKS 1.1 :7 Your script should prompt for a username

RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
at new NodeError (internal/errors.js:322:7)
at Socket.onChildStdout (child_process.js:443:14)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:263:11)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
  ✘ SUBTASKS 1.1 :8 Your script should print the correct welcome message for returning users

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(re.test(scriptOutput))

at Context.<anonymous> (test/1.1.test.js:98:5)
  ✘ SUBTASKS 1.1 :9 Your script should print the correct welcome message for new users

RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
at new NodeError (internal/errors.js:322:7)
at Socket.onChildStdout (child_process.js:443:14)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:263:11)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
  ✘ SUBTASKS 1.1 :12 Your script should print the correct message if users enter a guess other than a number

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)
  ✘ SUBTASKS 1.1 :13 Your script should print the correct message when a game is finished

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)

This one after TRUNCATE tables:

FAILED TEST LOG
  ✘ SUBTASKS 1.1 :7 Your script should prompt for a username

RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
at new NodeError (internal/errors.js:322:7)
at Socket.onChildStdout (child_process.js:443:14)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:263:11)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
  ✘ SUBTASKS 1.1 :8 Your script should print the correct welcome message for returning users

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)
  ✘ SUBTASKS 1.1 :9 Your script should print the correct welcome message for new users

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)
  ✘ SUBTASKS 1.1 :11 Your script should print the correct messages if they do not guess the correct number

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)
  ✘ SUBTASKS 1.1 :13 Your script should print the correct message when a game is finished

Error: Command failed: ./number_guessing_game/number_guess.sh

at ChildProcess.exithandler (child_process.js:383:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Pipe.<anonymous> (net.js:686:12)

Yeah, I spent two days to find a mistake and could not because everything is work.

So I guess I will return to the project sometimes to check if the test passing will be fixed.

If you’re getting ‘max buffer exceeded’ error messages in the test output, you could try increasing the buffer size by inserting {maxBuffer: 1024 * 500} in place of the empty curly brackets in the utils.js file here:
Untitled

Also highlighted is a timeout which can be increased if you’re getting child process errors. Set to 1000 initially, but here I increased it to 10000.

It sounds like you’re having trouble with the final exercise in the RB course, particularly with the output and the task related to the username. I understand how frustrating it can be when you’ve been working on something for days without finding a solution.

To help you troubleshoot the issue, it would be beneficial if you could provide some additional information. Please share the relevant parts of your code related to the username input and the output section. This will allow us to better understand the problem and provide you with specific guidance.

In the meantime, here are a few general suggestions:

Check the code related to the username input: Ensure that you have a prompt asking the user to enter their username and that the input is correctly stored in a variable.

Verify the code for the output section: Double-check that you are correctly formatting the output string and properly incorporating the variables for games played, best game, number of guesses, and secret number.

Pay attention to variable names: Make sure you are using the correct variable names throughout your code, especially when referencing the username and the game-related variables.

Review any recent changes: If you made modifications to the code and it affected the username input, carefully review the changes you made and consider undoing them or finding an alternative solution.

By providing more specific details about your code and any error messages you encounter, we’ll be able to assist you further in identifying the mistake and finding a solution.