DEV Community

Ivan Radunković
Ivan Radunković

Posted on

Pokemon API and React

Hi all.

I have a couple of questions.
I have Pokemon guessing game and pokedex. I can play it on localhost and I want to make some changes, for which I need your help.

1.) I want to have option to answer question in first capital letter if I want, now only time when I write answer in lowercase, it's correct, but I want it no matter what type of letter I wrote.
2.) Count of correct answer doesn't work. I get JS response that answer is correct but counter is still on 0.
3.) When counter is right, I want progress bar for answers, number of x/151 and percentage
4.) Also I have pokedex, and I want only to see Pokemon that I guess in guessing game.

Can someone please help me with that issues? What data do you need? Link to git repo or specific file?

Top comments (3)

Collapse
 
omkar76 profile image
Omkar76 • Edited

Before I try to answer let me introduce myself.

I'm not a JS expert.
I haven't touched react 😬.
I still love JS.
This is my first comment.

well, let me try.

  1. So you want case insensitive comparison of strings.
let pokemon = "pikachu";
let guess = prompt("What do you think it's? ");

if(guess.trim().toLowerCase() ===pokemon) {
  alert("That was correct!");
}else{
  alert("You need to do more  research");
}

first trim the string. Trim method removes leading and trailing white spaces from string.

convert user input to lowercase and then do comparison.

This is what I did in my code coach project on sololearn

Collapse
 
omkar76 profile image
Omkar76 • Edited
  1. Hard to say anything without reading you code ☺
Collapse
 
ivanradunkovic profile image
Ivan Radunković

Hi Omakar76, many thanks for your help.

This is my git repo with this issues

github.com/ivanradunkovic/Pokemon