Answer:
I will code in Javascript;
function findFirstComma() {
var pos;
var line = 'Thi,s is a t,est';
var clause;
pos = line.indexOf(','); //set pos in 3.
clause= line.slice(0,pos); // saves in clause the value 'Thi'.
}
Explanation:
The slice(start, end) method extract a part of a string then returns a new string with the extracted part. The end parameter indicates where to end the extraction(up to, but not including).
The includes(value) method determines if a string contains the characters on a specified string, if it doesn't match then returns -1.