Answer:
I will code in Javascript;
function findFirstComma() {
var pos;
var line = 'Thi,s is a t,est';
var clause;
pos = line.indexOf(','); <em>//set pos in 3.</em>
clause= line.slice(0,pos); <em>// saves in clause the value 'Thi'.</em>
}
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.