Looking for help

Hi! I’m doing my Quality Assurance Project ‘American -British Translator’ so far.
It’s listed on the last but it’s not gonna be my last one. I skipped several projects.
And I’ve realized it is on the last for reasons.
It’s freaking hard. I think my bran just stopped and I don’t know from where to start to solve problems.

Well, my translator is working but not perfectly.
Setting aside testing problems, I’m struggling the function of translator.

So my struggle point is

Can you toss this in the trashcan for me -> Can you toss this in the bin for me

it should be the answer but I get ’ Can you toss this in the rubbishcan for me?’
so I checked that there are ‘trashcan : bin’ and ‘trash: rubbish’ pairs in dictionary.
I’ve tried to figure this out but I am lost. It looks pretty simple to fix this but my foresight is blurry. Could anyone give me any tips if you have time and don’t mind to do this?

Link to my project : https://repl.it/@atiktook/boilerplate-project-american-british-english-translator#public/translator.js

if(mode === 'american-to-british'){

    answer = americanDic.filter(x => input.includes(x[0]))
  
    answer.forEach( word => 
    input = input.replace(word[0], "<span class='highlight' style='color:green'>" + word[1] + "</span>") 
    )
      if(input.match(amerTimeRegex)){
    changedTime = input.match(amerTimeRegex)[0].replace('\:', '\.')   
    input = input.replace(input.match(amerTimeRegex)[0], "<span class='highlight' style='color:green'>" + changedTime + "</span>")
    }
  }

the code regarding the problem…

Thank you in advance and sorry if my english is not clear enough to explain where I’m stuck right now.

Sounds like you need to make sure that you are only “translating” whole words, so you’ll need to be checking for spaces and punctuation.

1 Like

Thank you for the advice. I’m gonna try to fix it!!

@ArielLeslie Hi , Ariel again It’s me. I am sad to say this but I didn’t get why I need to check for spaces and punctuation. if you don’t mind could you explain about it more ? It will be really helpful . Thank you very much in advance.

Because spaces and punctuation are how we know when a word ends.
We may want to translate “egg” to “ovum” but we don’t want to translate “eggplant” to “ovumplant” (eww). We know that “egg” is a complete word because it is preceded by a space and followed by a comma, period, etc.

1 Like

thank you for the explanation . however, I was wondering because there are words with space and punctuation in the provided dictionary (words lists). so that’s why I didn’t think about the way of approach to solve this problem. hmmmm I’m still not so sure but i will give it a try. I can sound so dummy but this is what i have in my head, and if you have any time and still you don’t mind to explain it would be really thankful. thank you for the advice again .