Misleading and can lead to misunderstanding of mass spec. The reason you can tell if a substance you're analyzing contains bromine or chlorine is because of the characteristic ratio of 1:1 or 3:1 M:M+2 peaks (for a molecule containing a single bromine or chlorine, respectively). Bromine and chlorine exists as a mixture of isotopes with two substantial relative abundances:
Chlorine:
~(25% 37Cl and 75% 35Cl)
Bromine:
~(50% 79Br and 50% 81Br)
It's not that Br or Cl has a ratio relative to the M peak. Both the M and M+2 peak contain chlorine or bromine. It's that specifically the M (containing 35Cl) : M+2 (containing 37Cl) ratio is 3:1 and the M (containing 79Br) to M+2 (containing 81Br) ratio is 1:1 due to the relative abundance of the isotopes.
Explanation of Mass Spec including relative abundance of chlorine and bromine.
https://www.khanacademy.org/science/ap-chemistry-beta/x2eef969c74e0d802:atomic-structure-and-properties/x2eef969c74e0d802:mass-spectrometry-of-elements/a/isotopes-and-mass-spectrometry
Another explanation of mass spec (not directly relevant to Cl and Br but provides further general evidence for suggestion)
https://www.khanacademy.org/test-prep/mcat/physical-processes/atomic-nucleus/v/mass-spectrometer
Need to add specifically that this is the mass spectrum of a molecule containing a single chlorine or else this ratio is not true. For example, For molecules containing two chlorines .
Given: Chlorine: ~(25% 37Cl and 75% 35Cl)
35 + 35 = M
35 + 37 = M + 2
37 + 37 = M+4
(M+, M+2 and M+4) peak heights will be in the ratio of 9:6:1 when the compound contains 2 chlorine atoms based on probability/abundance. SO this no longer applies.
See to visualize for chlorine:
https://chem.libretexts.org/Courses/Providence_College/CHM_331_Advanced_Analytical_Chemistry_1/16%3A_Molecular_Mass_Spectrometry/16.09%3A_Organic_Compounds_Containing_Halogen_Atoms
Given: Bromine has two stable isotopes—bromine-\[79\] and bromine-\[81\]. The relative abundance of the isotopes are \[50.70\%\] and \[49.30\%\]
Therefore for molecule containing two bromine.
79 Br + 79 Br = M Peak
79 Br + 81 Br = M + 2 Peak
81 Br + 81 Br = M +4 Peak
79 Br + 81 Br = M + 2 Peak has highest abundance based on probability.
1:1 Ratio of 79 Br + 79 Br = M Peak to 81 Br + 81 Br = M +4 Peak
Note that although 79Br and 81Br are approximately in 1:1 ratio. Real abundance is 50.7 to 49.3 so this 1:1 ratio rule listed in extra section will theoretically fall apart at very a high number of Br in a molecule based on probability.
See to visualize for bromine:
https://chem.libretexts.org/Courses/Purdue/Chem_26505%3A_Organic_Chemistry_I_(Lipton)/Chapter_5._Spectroscopy/5.2_Mass_Spectrometry