The momentum-weighted sum of the electric charges of particles inside a jet, known as jet charge, is sensitive to the electric charge of the particle initiating the parton shower. This paper presents jet charge distributions in √ s NN = 5.02 TeV lead-lead (PbPb) and proton-proton (pp) collisions recorded with the CMS detector at the LHC. These data correspond to integrated luminosities of 404 µb −1 and 27.4 pb −1 for PbPb and pp collisions, respectively. Leveraging the sensitivity of the jet charge to fundamental differences in the electric charges of quarks and gluons, the jet charge distributions from simulated events are used as templates to extract the quark-and gluon-like jet fractions from data. The modification of these jet fractions is examined by comparing pp and PbPb data as a function of the overlap of the colliding Pb nuclei (centrality). This measurement tests the color charge dependence of jet energy loss due to interactions with the quark-gluon plasma. No significant modification between different centrality classes and with respect to pp results is observed in the extracted quark-and gluon-like jet fractions.