Question: I have very simple contract as..

```
contract myContract {
    function foo() public returns(uint) {
        return 10;
    }

    function foo1() public view returns(uint) {
        return 10;
    }    
}

```

But when I test my contract with truffle test.js(as follows).
Why the result is different with view and without view modifier?

here is parts of my test.js. 

```
temp1 = await instant.foo1();
console.log("temp1 value : " + temp1);
assert.equal(temp1, 10, "should be 10 return");     
temp1 = await instant.foo();
console.log("temp1 value : " + temp1);
assert.equal(temp1, 10, "should be 10 return");

```

And it is my result.

[![enter image description here](https://i.stack.imgur.com/x1BZ7.png)](https://i.stack.imgur.com/x1BZ7.png)

Answer: 
Because without the `view` modifier, web3 (and thus Truffle JS tests, which uses web3) thinks it has to send a transaction. Sending transactions does not yield a return value from the smart contract. 

Adding the `view` modifier tells web3 it can use `call` in order to get the function's return value. A `call`, however, cannot alter the contract's state. It cannot alter any storage variables.

If you want a function which alters the contract's state and does yield a value, you could create a function which emits an event. In that event, you could set the return value.
The view Modifier indicates, that you make no changes to the Blockchain and that the query of the uint wont require any gas cost.