Ask Question
25 July, 16:19

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.

+2
Answers (1)
  1. 25 July, 17: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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers