function search() {
var infoOne = document.getElementsByClassName('infoOne');
var infoTwo = document.getElementsByClassName('infoTwo');
var contents = [];
for (var i=0; i < infoOne.length; i++) {
contents[i] = [infoOne[i].innerText || infoOne[i].textContent || '', infoTwo[i].innerText || infoTwo[i].textContent || ''].join(' - ');
}
var result = contents.join('\n'); // для html - join('<br/>')
alert( result );
}