Ask 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, 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.

+5
Answers (1)
  1. 22 August, 18:37
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers