The simplest answer is someone tried it and published their findings.
You can reasonably guess which chemicals should react more strongly to others but it is pretty much a guess unless you find previous research.
Most chemistry I’ve seen is you add A to B to get C, add C to D to get E and so on until you get the compound you want.
NileRed on YouTube is pretty good at explaining chemistry and does some fun experiments where you see the process.
Latest Answers