17 And as he was setting out on his journey, a man ran up and knelt before him and asked him, “Good Teacher, what must I do to inherit eternal life?” 18 And Jesus said to him, “Why do you call me good? No one is good except God alone. 19 You know the commandments: ‘Do not murder, Do not commit adultery, Do not steal, Do not bear false witness, Do not defraud, Honor your father and mother.’” 20 And he said to him, “Teacher, all these I have kept from my youth.” 21 And Jesus, looking at him, loved him, and said to him, “You lack one thing: go, sell all that you have and give to the poor, and you will have treasure in heaven; and come, follow me.” [Mark 10:17-21 ESV]
25 And behold, a lawyer stood up to put him to the test, saying, “Teacher, what shall I do to inherit eternal life?” 26 He said to him, “What is written in the Law? How do you read it?” 27 And he answered, “You shall love the Lord your God with all your heart and with all your soul and with all your strength and with all your mind, and your neighbor as yourself.” 28 And he said to him, “You have answered correctly; do this, and you will live.” [Luke 10:25-28 ESV]
Did Jesus preach works-based salvation in both passages? How does salvation by faith fit into all this?