Ask Question
10 November, 01:12

Write a sequence of statements that finds the first comma in the string line, and assigns to the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos, as well as the variables line and clause, have already been declared.

+3
Answers (1)
  1. 10 November, 01:27
    0
    I will code in jа vascript;

    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a sequence of statements that finds the first comma in the string line, and assigns to the variable clause the portion of line up to, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers