Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="results">
</div>

              
            
!

CSS

              
                .bbgreen {
	color: green;
	font-weight: bold;
}

body {
	font-size: 20px;	
	line-height: 30px;
}
              
            
!

JS

              
                const elements = [
  'Uue', 'He', 'Li', 'Be', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'Cl',
  'Ar',  'Ca', 'Sc', 'Ti', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu',
  'Zn',  'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Zr',
  'Nb',  'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn',
  'Sb',  'Te', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm',
  'Sm',  'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu',
  'Hf',  'Ta', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb',
  'Bi',  'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'Np',
  'Pu',  'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr',
  'Rf',  'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh',
  'Fl',  'Mc', 'Lv', 'Ts', 'Og', 'H',  'B',  'C',  'N',  'O',
  'F',   'P',  'S',  'K',  'V',  'Y',  'I',  'W',  'U'
];

const names = [
	'Raymond Camden',
  'Pilar Marquez',
  'Daniela Molina',
  'Maja Rasmussen',
  'Konsta Couri',
  'Lærke Jørgensen',
  'Ryan Taylor',
  'Phil Banks',
  'Rasmus Heinonen',
  'Gabriel Bélanger',
  'Panagiotis Van den Brom',
  'Frederik Thomsen',
  'Selin Eidsvik',
  'Villads Kristensen',
  'Oskari Jarvi',
  'Kenan Uluhan',
  'Steven Mills',
  'Juni Hofstad',
  'Ryder Knight',
  'Brandie Welch',
  'Aline Kommedal',
  'Mira Lima',
  'Rasmus Christensen',
  'Yasir Solbu',
  'Marine Dupont',
  'Linnea Bauge',
  'Albano Fogaça',
  'Oliver Laakso',
  'Amber Walker',
  'Adeline Naß',
  'Mohamed Muñoz',
  'Lewis Cole',
  'Lester Ward',
  'Celia Hustad',
  'Cacharel Coops',
  'Aquira Mendes',
  'Johanne Hansen',
  'Letitia Gilbert',
  'Jenny Lewis',
  'Franca Carpentier',
  'Ernesta Moura',
  'Natalia Ibañez',
  'Mariam Kampen',
  'Jayden Taylor',
  'Zarah Dirkx',
  'Ottokar Führer',
  'Romain Legrand',
  'Blake Gauthier',
  'Susana Herrero',
  'Elliot Taylor',
  'Kaitlin Willis',
  'Evan Gonzalez',
  'Samantha Bell',
  'Bowe Fontijn',
  'Wallace Bates',
  'Raymond Ross',
  'Kuzey Bayındır',
  'Monica Moya',
  'Jackson Little',
  'Clifford Roberts',
  'Gary Day',
  'Tilde Do',
  'Chloe Lévesque',
  'Vicki Ryan',
  'John Armstrong',
  'Constâncio Monteiro',
  'Phillip Hall',
  'Bruce Little',
  'Amanda Alexander',
  'Juho Kauppi',
  'Carolina Handke',
  'Leo Walker',
  'Michele Ellis',
  'Mar Carmona',
  'Kim Carpentier',
  'Matthieu Menard',
  'Vemund Søgård',
  'Marianne Ma',
  'Freja Christiansen',
  'Josefina Garrido',
  'Hazel Hunter',
  'Lutero Costa',
  'Daniel Lammi',
  'Expedita das Neves',
  'Juan Herrera',
  'Carina Rosland',
  'Liam Brown',
  'Steve Mills',
  'Iker Cano',
  'اميرحسين احمدی',
  'Arthur Tremblay',
  'Marie Austin',
  'Aurora Crespo',
  'Jimmy Holt',
  'Marie Christensen',
  'Jared Washington'
];

function bbString(input, className, elements) {
	// loop through elements and once we find ONE match, return
	let lcaseInput = input.toLowerCase();
	for(let i=0; i<elements.length; i++) {
		let elem = elements[i];
		let match = lcaseInput.indexOf(elem.toLowerCase());
		if(match >= 0) {
			//console.log(`I matchned ${elem} in ${lcaseInput}`);
			return input.substring(0, match) + `<span class="${className}">` + elem + "</span>" + input.substring(match + elem.length);
		}
	}
	return input;
}

let resultDiv = document.querySelector('#results');
//console.log(bbString('Raymond Camden', 'bbgreen', elements));
let html = '';
names.forEach(n => {
	html += bbString(n, 'bbgreen', elements) + '<br/>';
});

resultDiv.innerHTML = html;


              
            
!
999px

Console